Blob Blame History Raw
From e9779d3f6c4fae7ed59921a8f8ca8b2875aafbf0 Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com>
Date: Wed, 7 Nov 2018 09:45:00 +0100
Subject: [PATCH 1/5] mm: print more information about mapping in __dump_page
Git-commit: 1c6fb1d89e73cd3bbfae7c400f1c615272aa435f
Patch-mainline: v5.0-rc1
References: generic hotplug debugability

__dump_page prints the mapping pointer but that is quite unhelpful
for many reports because the pointer itself only helps to distinguish
anon/ksm mappings from other ones (because of lowest bits
set). Sometimes it would be much more helpful to know what kind of
mapping that is actually and if we know this is a file mapping then also
try to resolve the dentry name.

Signed-off-by: Michal Hocko <mhocko@suse.com>

---
 mm/debug.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/mm/debug.c
+++ b/mm/debug.c
@@ -48,6 +48,7 @@ void __dump_page(struct page *page, cons
 	 * encode own info.
 	 */
 	int mapcount = PageSlab(page) ? 0 : page_mapcount(page);
+	struct address_space *mapping = page_mapping(page);
 
 	pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx",
 		  page, page_ref_count(page), mapcount,
@@ -56,6 +57,18 @@ void __dump_page(struct page *page, cons
 		pr_cont(" compound_mapcount: %d", compound_mapcount(page));
 	pr_cont("\n");
 	BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1);
+	if (PageAnon(page))
+		pr_emerg("anon ");
+	else if (PageKsm(page))
+		pr_emerg("ksm ");
+	else if (mapping) {
+		pr_emerg("%ps ", mapping->a_ops);
+		if (mapping->host->i_dentry.first) {
+			struct dentry *dentry;
+			dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias);
+			pr_emerg("name:\"%pd\" ", dentry);
+		}
+	}
 
 	pr_emerg("flags: %#lx(%pGp)\n", page->flags, &page->flags);