mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] MM: Tighten control over zero-page remapping
@ 2026-10-25 17:39 Nico Pache (Red Hat)
  2026-10-25 17:39 ` [PATCH v2 1/2] mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled Nico Pache (Red Hat)
  2026-10-25 17:39 ` [PATCH v2 2/2] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits Nico Pache (Red Hat)
  0 siblings, 2 replies; 9+ messages in thread
From: Nico Pache (Red Hat) @ 2026-10-25 17:39 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Andrew Morton, David Hildenbrand, Zi Yan, Baolin Wang,
	Liam R. Howlett, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
	Usama Arif, Kiryl Shutsemau, Yu Zhao, Xu Xin, Chengming Zhou,
	Matthew Brost, Joshua Hahn, Byungchul Park, Gregory Price,
	Ying Huang, Alistair Popple, Usama Arif, aarcange,
	Nico Pache (Red Hat)

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.

V2 Changes:
- Dropped ksm_is_running() and its EXPORT_SYMBOL_GPL (Lorenzo).
- Replaced the v1 approach with a narrower check:
  introduce current_is_ksmd() to detect ksmd and only skip zero-page
  remapping when the split is triggered by ksmd itself. This avoids
  disabling the underused THP shrinker's zero-page reclaim on VM_MERGEABLE
  mappings when the split is caused by something other than KSM.

V1: https://lore.kernel.org/all/20260609114619.144416-1-npache@redhat.com/
RFC: https://lore.kernel.org/all/20260508170509.640851-1-npache@redhat.com/

Signed-off-by: Nico Pache (Red Hat) <nico.pache@linux.dev>
---
Nico Pache (Red Hat) (2):
      mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled
      mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits

 include/linux/ksm.h | 6 ++++++
 mm/huge_memory.c    | 3 ++-
 mm/ksm.c            | 5 +++++
 mm/migrate.c        | 3 +++
 4 files changed, 16 insertions(+), 1 deletion(-)
---
base-commit: a2abad0d7f453cc9902fc8bf7b871db5563a652c
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-unstable
change-id: 20261025-b4-ksm_fixv2-2bf062e92946

Best regards,
--  
Nico Pache (Red Hat) <nico.pache@linux.dev>


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

end of thread, other threads:[~2026-10-26 21:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 17:39 [PATCH v2 0/2] MM: Tighten control over zero-page remapping Nico Pache (Red Hat)
2026-10-25 17:39 ` [PATCH v2 1/2] mm/huge_memory.c: skip zero-page remapping when underused THP shrinker is disabled Nico Pache (Red Hat)
2026-10-25 20:28   ` Barry Song
2026-10-25 21:48     ` Nico Pache
2026-10-26  4:52       ` Barry Song
2026-10-26 20:02         ` Nico Pache
2026-10-26 20:58           ` Barry Song
2026-10-26 21:33             ` Nico Pache
2026-10-25 17:39 ` [PATCH v2 2/2] mm/ksm: prevent zero-page remapping during ksmd-triggered THP splits Nico Pache (Red Hat)

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

all inboxes | Powered by JetHome®