Blob Blame History Raw
From e588630182fafe3fc06e167aa8cf1fe72c4ef296 Mon Sep 17 00:00:00 2001
From: Ralph Campbell <rcampbell@nvidia.com>
Date: Fri, 15 Nov 2019 17:35:07 -0800
Subject: [PATCH] mm/debug.c: PageAnon() is true for PageKsm() pages

References: git fixes (mm/debug)
Patch-mainline: v5.4
Git-commit: 6855ac4acd3bad4a5caf813b0e401a0bc79a54a9

PageAnon() and PageKsm() use the low two bits of the page->mapping
pointer to indicate the page type.  PageAnon() only checks the LSB while
PageKsm() checks the least significant 2 bits are equal to 3.

Therefore, PageAnon() is true for KSM pages.  __dump_page() incorrectly
will never print "ksm" because it checks PageAnon() first.  Fix this by
checking PageKsm() first.

Link: http://lkml.kernel.org/r/20191113000651.20677-1-rcampbell@nvidia.com
Fixes: 1c6fb1d89e73 ("mm: print more information about mapping in __dump_page")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 mm/debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/debug.c b/mm/debug.c
index 3fbbd0adb4f6..5a05940f945d 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -57,10 +57,10 @@ void __dump_page(struct page *page, const char *reason)
 		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_warn("anon ");
-	else if (PageKsm(page))
+	if (PageKsm(page))
 		pr_warn("ksm ");
+	else if (PageAnon(page))
+		pr_warn("anon ");
 	else if (mapping) {
 		pr_warn("%ps ", mapping->a_ops);
 		if (mapping->host && mapping->host->i_dentry.first) {