diff mbox series

[06/11] mm/huge_memory: Fix page_trans_huge_mapcount assumption of THP size

Message ID 20200908195539.25896-7-willy@infradead.org
State New
Headers show
Series Remove assumptions of THP size | expand

Commit Message

Matthew Wilcox (Oracle) Sept. 8, 2020, 7:55 p.m. UTC
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(-)

Comments

Kirill A. Shutemov Sept. 9, 2020, 2:45 p.m. UTC | #1
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>
SeongJae Park Sept. 15, 2020, 7:24 a.m. UTC | #2
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 mbox series

Patch

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;