The patch titled Subject: mm/thp: update mm_struct's MM_ANONPAGES stat for huge zero pages has been added to the -mm tree. Its filename is mm-thp-update-mm_structs-mm_anonpages-stat-for-huge-zero-pages.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-thp-update-mm_structs-mm_anonpages-stat-for-huge-zero-pages.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-thp-update-mm_structs-mm_anonpages-stat-for-huge-zero-pages.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: Anshuman Khandual <anshuman.khandual@xxxxxxx> Subject: mm/thp: update mm_struct's MM_ANONPAGES stat for huge zero pages Although the zero huge page is being shared across various processes, each mapping needs to update its mm_struct's MM_ANONPAGES stat by HPAGE_PMD_NR to be consistent. This just updates the stats in set_huge_zero_page() after the mapping gets created and in zap_huge_pmd() when mapping gets destroyed. Link: https://lkml.kernel.org/r/1621313300-1118-1-git-send-email-anshuman.khandual@xxxxxxx Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx> Reviewed-by: Zi Yan<ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/huge_memory.c~mm-thp-update-mm_structs-mm_anonpages-stat-for-huge-zero-pages +++ a/mm/huge_memory.c @@ -715,6 +715,7 @@ static void set_huge_zero_page(pgtable_t if (pgtable) pgtable_trans_huge_deposit(mm, pmd, pgtable); set_pmd_at(mm, haddr, pmd, entry); + add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR); mm_inc_nr_ptes(mm); } @@ -1627,6 +1628,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, spin_unlock(ptl); } else if (is_huge_zero_pmd(orig_pmd)) { zap_deposited_table(tlb->mm, pmd); + add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); spin_unlock(ptl); } else { struct page *page = NULL; _ Patches currently in -mm which might be from anshuman.khandual@xxxxxxx are mm-thp-update-mm_structs-mm_anonpages-stat-for-huge-zero-pages.patch mm-define-default-value-for-first_user_address.patch