diff options
author | Kirill A. Shutemov <kirill@shutemov.name> | 2020-10-15 20:05:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-10-16 11:11:15 -0700 |
commit | 86b562b629728a072e6928bdc02a105d358a007d (patch) | |
tree | 3f4c2ca3b8deb47ba07da752b090c97b294b5240 /mm/huge_memory.c | |
parent | 8fb156c9ee2db94f7127c930c89917634a1a9f56 (diff) | |
download | lwn-86b562b629728a072e6928bdc02a105d358a007d.tar.gz lwn-86b562b629728a072e6928bdc02a105d358a007d.zip |
mm/huge_memory: fix total_mapcount assumption of page size
File THPs may now be of arbitrary order.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SeongJae Park <sjpark@amazon.de>
Cc: Huang Ying <ying.huang@intel.com>
Link: https://lkml.kernel.org/r/20200908195539.25896-5-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r-- | mm/huge_memory.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index aa612cc5b3fe..b63c98516a7c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2494,7 +2494,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, int total_mapcount(struct page *page) { - int i, compound, ret; + int i, compound, nr, ret; VM_BUG_ON_PAGE(PageTail(page), page); @@ -2502,16 +2502,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; } |