Message ID | 20200908195539.25896-7-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Remove assumptions of THP size | expand |
On Tue, Sep 08, 2020 at 08:55:33PM +0100, Matthew Wilcox (Oracle) wrote: > Ask the page what size it is instead of assuming it's PMD size. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
On Tue, 8 Sep 2020 20:55:33 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote: > Ask the page what size it is instead of assuming it's PMD size. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: SeongJae Park <sjpark@amazon.de> Thanks, SeongJae Park
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7bf837c32e3f..e9503b10df8f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2522,14 +2522,14 @@ int page_trans_huge_mapcount(struct page *page, int *total_mapcount) page = compound_head(page); _total_mapcount = ret = 0; - for (i = 0; i < HPAGE_PMD_NR; i++) { + for (i = 0; i < thp_nr_pages(page); i++) { mapcount = atomic_read(&page[i]._mapcount) + 1; ret = max(ret, mapcount); _total_mapcount += mapcount; } if (PageDoubleMap(page)) { ret -= 1; - _total_mapcount -= HPAGE_PMD_NR; + _total_mapcount -= thp_nr_pages(page); } mapcount = compound_mapcount(page); ret += mapcount;
Ask the page what size it is instead of assuming it's PMD size. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)