Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/proc: fix KPF_KSM reported for all anonymous pages
@ 2026-06-22  9:15 Jinjiang Tu
  2026-06-22 11:45 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 8+ messages in thread
From: Jinjiang Tu @ 2026-06-22  9:15 UTC (permalink / raw)
  To: akpm, ziy, david, luizcap, willy, linmiaohe, svetly.todorov,
	xu.xin16, chengming.zhou, linux-fsdevel, linux-mm
  Cc: wangkefeng.wang, sunnanyong, tujinjiang

Reading /proc/kpageflags for any anonymous page returns KPF_KSM set, even
when KSM is not in use. As a result, tools misclassify all anonymous pages
as KSM merged.

In stable_page_flags(), if the page is anonymous, then use (mapping &
FOLIO_MAPPING_KSM) check to identify if the anonymous page is KSM page.
However, FOLIO_MAPPING_KSM is FOLIO_MAPPING_ANON | FOLIO_MAPPING_ANON_KSM,
(mapping & FOLIO_MAPPING_KSM) check returns true for all nonymous pages.

To fix it, use FOLIO_MAPPING_ANON_KSM instead.

Fixes: dee3d0bef2b0 ("proc: rewrite stable_page_flags()")
Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
---
 fs/proc/page.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/page.c b/fs/proc/page.c
index f9b2c2c906cd..cef8ded97610 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -173,7 +173,7 @@ u64 stable_page_flags(const struct page *page)
 		u |= 1 << KPF_MMAP;
 	if (is_anon) {
 		u |= 1 << KPF_ANON;
-		if (mapping & FOLIO_MAPPING_KSM)
+		if (mapping & FOLIO_MAPPING_ANON_KSM)
 			u |= 1 << KPF_KSM;
 	}
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-25 11:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22  9:15 [PATCH] fs/proc: fix KPF_KSM reported for all anonymous pages Jinjiang Tu
2026-06-22 11:45 ` David Hildenbrand (Arm)
2026-06-22 12:00   ` David Hildenbrand (Arm)
2026-06-23  1:37   ` Jinjiang Tu
2026-06-25  1:00     ` Andrew Morton
2026-06-25  6:38       ` David Hildenbrand (Arm)
2026-06-25  6:39     ` David Hildenbrand (Arm)
2026-06-25 11:21       ` Jinjiang Tu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox