[RFC PATCH 16/31] mm: thp: check compound_mapcount of PMD-mapped PUD THPs at free time.

From: Zi Yan
Date: Fri Feb 15 2019 - 17:10:47 EST


From: Zi Yan <ziy@xxxxxxxxxx>

PMD mappings on a PUD THP should be zero when the page is freed.

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

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dbcccc022b30..b87a2ca0a97c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1007,8 +1007,10 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
/* sub_compound_map_ptr store here */
if (compound_order(head_page) == HPAGE_PUD_ORDER &&
(page - head_page) % HPAGE_PMD_NR == 3) {
- if (unlikely(atomic_read(&page->compound_mapcount) != -1))
+ if (unlikely(atomic_read(&page->compound_mapcount) != -1)) {
+ pr_err("sub_compound_mapcount: %d\n", atomic_read(&page->compound_mapcount) + 1);
bad_page(page, "nonzero sub_compound_mapcount", 0);
+ }
break;
}
if (page->mapping != TAIL_MAPPING) {
--
2.20.1