diff mbox series

[v2,1/8] mm: dump_page: print head page's refcount, for compound pages

Message ID 20200129032417.3085670-2-jhubbard@nvidia.com
State New
Headers show
Series [v2,1/8] mm: dump_page: print head page's refcount, for compound pages | expand

Commit Message

John Hubbard Jan. 29, 2020, 3:24 a.m. UTC
When debugging a problem that involves compound pages, it is extremely
helpful if dump_page() reports not only the page->_refcount, but also
the refcount of the head page of the compound page. That's because the
head page collects refcounts for the entire compound page.

Therefore, enhance dump_page() so as to print out the refcount of the
head page of a compound page.

This approach (printing information about a struct page that is not the
struct page that was passed into dump_page()) has a precedent:
compound_mapcount is already being printed.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 mm/debug.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/mm/debug.c b/mm/debug.c
index a90da5337c14..4cc6cad8385d 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -76,9 +76,11 @@  void __dump_page(struct page *page, const char *reason)
 	mapcount = PageSlab(page) ? 0 : page_mapcount(page);
 
 	if (PageCompound(page))
-		pr_warn("page:%px refcount:%d mapcount:%d mapping:%px "
-			"index:%#lx compound_mapcount: %d\n",
-			page, page_ref_count(page), mapcount,
+		pr_warn("page:%px refcount:%d head refcount:%d "
+			"mapcount:%d mapping:%px index:%#lx "
+			"compound_mapcount:%d\n",
+			page, page_ref_count(page),
+			page_ref_count(compound_head(page)), mapcount,
 			page->mapping, page_to_pgoff(page),
 			compound_mapcount(page));
 	else