The patch titled Subject: mm/huge_memory: fix total_mapcount assumption of page size has been added to the -mm tree. Its filename is mm-huge_memory-fix-total_mapcount-assumption-of-page-size.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-huge_memory-fix-total_mapcount-assumption-of-page-size.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-huge_memory-fix-total_mapcount-assumption-of-page-size.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: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx> Subject: mm/huge_memory: fix total_mapcount assumption of page size File THPs may now be of arbitrary order. Link: https://lkml.kernel.org/r/20200908195539.25896-5-willy@xxxxxxxxxxxxx Signed-off-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Huang Ying <ying.huang@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/mm/huge_memory.c~mm-huge_memory-fix-total_mapcount-assumption-of-page-size +++ a/mm/huge_memory.c @@ -2465,7 +2465,7 @@ static void __split_huge_page(struct pag int total_mapcount(struct page *page) { - int i, compound, ret; + int i, compound, nr, ret; VM_BUG_ON_PAGE(PageTail(page), page); @@ -2473,16 +2473,17 @@ int total_mapcount(struct page *page) return atomic_read(&page->_mapcount) + 1; compound = compound_mapcount(page); + nr = compound_nr(page); if (PageHuge(page)) return compound; ret = compound; - for (i = 0; i < HPAGE_PMD_NR; i++) + for (i = 0; i < nr; i++) ret += atomic_read(&page[i]._mapcount) + 1; /* File pages has compound_mapcount included in _mapcount */ if (!PageAnon(page)) - return ret - compound * HPAGE_PMD_NR; + return ret - compound * nr; if (PageDoubleMap(page)) - ret -= HPAGE_PMD_NR; + ret -= nr; return ret; } _ Patches currently in -mm which might be from kirill@xxxxxxxxxxxxx are mm-huge_memory-fix-total_mapcount-assumption-of-page-size.patch mm-huge_memory-fix-split-assumption-of-page-size.patch