Skip to contentSkip to conversation

fs-proc-fix-kpf_ksm-reported-for-all-anonymous-pages.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Jul 2 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: fs/proc: fix KPF_KSM reported for all anonymous pages
has been removed from the -mm tree. Its filename was
fs-proc-fix-kpf_ksm-reported-for-all-anonymous-pages.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jinjiang Tu <[email protected]>
Subject: fs/proc: fix KPF_KSM reported for all anonymous pages
Date: Fri, 26 Jun 2026 09:32:52 +0800

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 anonymous pages.

To fix it, use FOLIO_MAPPING_ANON_KSM instead.

---

 fs/proc/page.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/page.c renamed from fs/proc/page.c~fs-proc-fix-kpf_ksm-reported-for-all-anonymous-pages +1 -1
@@ -173,7 +173,7 @@ u64 stable_page_flags(const struct page
 		u |= 1 << KPF_MMAP;
 	if (is_anon) {
 		u |= 1 << KPF_ANON;
-		if (mapping & FOLIO_MAPPING_KSM)
+		if ((mapping & FOLIO_MAPPING_FLAGS) == FOLIO_MAPPING_KSM)
 			u |= 1 << KPF_KSM;
 	}
 

_

Patches currently in -mm which might be from [email protected] are