The patch titled Subject: mm: thp: clear PageDoubleMap flag when the last PMD map gone has been added to the -mm tree. Its filename is mm-thp-clear-pagedoublemap-flag-when-the-last-pmd-map-gone.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-thp-clear-pagedoublemap-flag-when-the-last-pmd-map-gone.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-thp-clear-pagedoublemap-flag-when-the-last-pmd-map-gone.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: clear PageDoubleMap flag when the last PMD map gone File THP sets PageDoubleMap flag when the first it gets PTE mapped, but the flag is never cleared until the THP is freed. This result in unbalanced state although it is not a big deal. Clear the flag when the last compound_mapcount is gone. It should be cleared when all the PTE maps are gone (become PMD mapped only) as well, but this needs check all subpage's _mapcount every time any subpage's rmap is removed, the overhead may be not worth. The anonymous THP also just clears PageDoubleMap flag when the last PMD map is gone. Link: http://lkml.kernel.org/r/1571938066-29031-1-git-send-email-yang.shi@xxxxxxxxxxxxxxxxx Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Acked-by: Song Liu <songliubraving@xxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/rmap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/rmap.c~mm-thp-clear-pagedoublemap-flag-when-the-last-pmd-map-gone +++ a/mm/rmap.c @@ -1256,6 +1256,9 @@ static void page_remove_file_rmap(struct __dec_node_page_state(page, NR_SHMEM_PMDMAPPED); else __dec_node_page_state(page, NR_FILE_PMDMAPPED); + + /* The last PMD map is gone */ + ClearPageDoubleMap(compound_head(page)); } else { if (!atomic_add_negative(-1, &page->_mapcount)) goto out; _ Patches currently in -mm which might be from yang.shi@xxxxxxxxxxxxxxxxx are mm-thp-handle-page-cache-thp-correctly-in-pagetranscompoundmap.patch mm-thp-handle-page-cache-thp-correctly-in-pagetranscompoundmap-v4.patch mm-vmscan-remove-unused-scan_control-parameter-from-pageout.patch mm-thp-clear-pagedoublemap-flag-when-the-last-pmd-map-gone.patch