On 8/27/19 1:02 PM, Kirill A. Shutemov wrote: > On Tue, Aug 27, 2019 at 08:01:39AM +0200, Michal Hocko wrote: >> On Mon 26-08-19 16:15:38, Kirill A. Shutemov wrote: >>> >>> Unmapped completely pages will be freed with current code. Deferred split >>> only applies to partly mapped THPs: at least on 4k of the THP is still >>> mapped somewhere. >> >> Hmm, I am probably misreading the code but at least current Linus' tree >> reads page_remove_rmap -> [page_remove_anon_compound_rmap ->\ deferred_split_huge_page even >> for fully mapped THP. > > Well, you read correctly, but it was not intended. I screwed it up at some > point. > > See the patch below. It should make it work as intened. > > It's not bug as such, but inefficientcy. We add page to the queue where > it's not needed. But that adding to queue doesn't affect whether the page will be freed immediately if there are no more partial mappings, right? I don't see deferred_split_huge_page() pinning the page. So your patch wouldn't make THPs freed immediately in cases where they haven't been freed before immediately, it just fixes a minor inefficiency with queue manipulation?