[PATCH mm-unstable v1 0/3] MM: Tighten control over zero-page remapping

From: Nico Pache

Date: Tue Jun 09 2026 - 07:54:19 EST


This patch series fixes a bug in KSM where the pages_to_scan limit is
bypassed and the policy (use_zero_pages) is ignored. It also gives users
further control of the zero-page remapping that occurs when a folio is
split.

Commit b1f202060afe ("mm: remap unused subpages to shared zeropage when
splitting isolated thp") added unconditional zero-page remapping when a
folio is split. This was sold as part of the underutilized shrinker, but
has a larger effect. Since this commit, all splits do this zero-page
scanning and remapping, even if the user has the underutilized shrinker
disabled.

This unconditional zero-page remapping was also problematic for KSM, as
when KSM would try to merge a page, it would split the folio and the
zero-page remapping would remap all zero-filled pages to the shared
zero-page bypassing the use_zero_pages policy. When the user had this
feature disabled, KSM would then waste cycles scanning these already
freed pages, causing little progress to be made, and KSMs performance to
degrade.

In this series we also gate the zero-page remapping behind
split_underused_thp (the sysfs for the underutilized shrinker). This
provides users with more control over this behavior, while also preventing
the KSM bug when it is enabled.

RFC: https://lore.kernel.org/all/20260508170509.640851-1-npache@xxxxxxxxxx/

Nico Pache (3):
mm/ksm: export ksm_is_running() to check KSM merge state
mm/migrate.c: Prevent folio splitting from interacting with KSM
mm/huge_memory.c: Skip zero-page remapping when underused THP shrinker
is disabled

include/linux/ksm.h | 6 ++++++
mm/huge_memory.c | 2 +-
mm/ksm.c | 6 ++++++
mm/migrate.c | 9 +++++++++
4 files changed, 22 insertions(+), 1 deletion(-)


base-commit: be18cf77e1e749c6469ff44df00eb026f7c0a365
--
2.54.0