[RFC PATCH v2 13/30] mm: rmap: add map_order to page_remove_anon_compound_rmap.

From: Zi Yan
Date: Mon Sep 28 2020 - 14:02:55 EST


From: Zi Yan <ziy@xxxxxxxxxx>

When PMD-mapped PUD THP is enabled by the upcoming commits, we can unmap
a PMD-mapped PUD THP that should be counted as NR_ANON_THPS. The added
map_order tells us about this situation.

Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
---
mm/rmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 0d922e5fb38c..7fc0bf07b9bc 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1292,7 +1292,7 @@ static void page_remove_file_rmap(struct page *page, bool compound)
clear_page_mlock(page);
}

-static void page_remove_anon_compound_rmap(struct page *page)
+static void page_remove_anon_compound_rmap(struct page *page, int map_order)
{
int i, nr;

@@ -1306,7 +1306,7 @@ static void page_remove_anon_compound_rmap(struct page *page)
if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
return;

- if (thp_nr_pages(page) == HPAGE_PMD_NR)
+ if (map_order == HPAGE_PMD_ORDER)
__dec_lruvec_page_state(page, NR_ANON_THPS);
else
__dec_lruvec_page_state(page, NR_ANON_THPS_PUD);
@@ -1357,7 +1357,7 @@ void page_remove_rmap(struct page *page, int map_order)
}

if (compound) {
- page_remove_anon_compound_rmap(page);
+ page_remove_anon_compound_rmap(page, map_order);
goto out;
}

--
2.28.0