The patch titled Subject: mm: thp: fix false negative of shmem vma's THP eligibility has been added to the -mm tree. Its filename is mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Subject: mm: thp: fix false negative of shmem vma's THP eligibility 7635d9cbe832 ("mm, thp, proc: report THP eligibility for each vma") introduced THPeligible bit for processes' smaps. But, when checking the eligibility for shmem vma, __transparent_hugepage_enabled() is called to override the result from shmem_huge_enabled(). It may result in the anonymous vma's THP flag override shmem's. For example, running a simple test which create THP for shmem, but with anonymous THP disabled, when reading the process's smaps, it may show: 7fc92ec00000-7fc92f000000 rw-s 00000000 00:14 27764 /dev/shm/test Size: 4096 kB ... [snip] ... ShmemPmdMapped: 4096 kB ... [snip] ... THPeligible: 0 And, /proc/meminfo does show THP allocated and PMD mapped too: ShmemHugePages: 4096 kB ShmemPmdMapped: 4096 kB This doesn't make too much sense. The anonymous THP flag should not intervene shmem THP. Calling shmem_huge_enabled() with checking MMF_DISABLE_THP sounds good enough. And, we could skip stack and dax vma check since we already checked if the vma is shmem already. Link: http://lkml.kernel.org/r/1555971893-52276-1-git-send-email-yang.shi@xxxxxxxxxxxxxxxxx Fixes: 7635d9cbe832 ("mm, thp, proc: report THP eligibility for each vma") Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 4 ++-- mm/shmem.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) --- a/mm/huge_memory.c~mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility +++ a/mm/huge_memory.c @@ -67,8 +67,8 @@ bool transparent_hugepage_enabled(struct { if (vma_is_anonymous(vma)) return __transparent_hugepage_enabled(vma); - if (vma_is_shmem(vma) && shmem_huge_enabled(vma)) - return __transparent_hugepage_enabled(vma); + if (vma_is_shmem(vma)) + return shmem_huge_enabled(vma); return false; } --- a/mm/shmem.c~mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility +++ a/mm/shmem.c @@ -3873,6 +3873,8 @@ bool shmem_huge_enabled(struct vm_area_s loff_t i_size; pgoff_t off; + if (test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags)) + return false; if (shmem_huge == SHMEM_HUGE_FORCE) return true; if (shmem_huge == SHMEM_HUGE_DENY) _ Patches currently in -mm which might be from yang.shi@xxxxxxxxxxxxxxxxx are mm-thp-fix-false-negative-of-shmem-vmas-thp-eligibility.patch doc-mm-migration-doesnt-use-foll_split-anymore.patch