[PATCH v2 0/4] mm: honour compact_unevictable_allowed in mlock and CMA paths

From: Wandun Chen

Date: Tue Jul 07 2026 - 08:59:52 EST


From: Wandun Chen <chenwandun@xxxxxxxxxxx>

vm.compact_unevictable_allowed=0 (the default on RT) is meant to keep
compaction from touching unevictable folios. Several paths still migrate
folios that are about to become unevictable, or in CMA regions,
installing migration entries that a later access must wait on, then
causing latency spikes on RT kernels.

This series fixes those paths and adds a tracepoint for diagnosis. It is
a rework of the RFC [1] per review feedback, mainly from Vlastimil.

RFC --> v2:
1. On top of the isolate-path filtering, also filter by VM_LOCKED
during the migration unmap step.

2. Make mlock/mlockall wait for in-flight migration entries, ensuring
the folio is on the unevictable LRU before mlock[all] returns.

3. Dropped letting CMA migration take unevictable folios; instead
migrate CMA folios out during mlock[all], avoiding migration at
cma_alloc time.

4. Moved the tracepoint to the migration unmap path.

[1] https://lore.kernel.org/lkml/20260604023812.3700316-1-chenwandun1@xxxxxxxxx/

Wandun Chen (4):
mm/migrate: do not migrate folios mapped into VM_LOCKED VMAs under
compaction
mm/mlock: wait for migration to finish when mlocking a folio
mm/migrate: add tracepoint for folios unmapped during migration
mm/mlock: migrate folios out of CMA when mlocking a range

include/linux/compaction.h | 6 ++
include/linux/rmap.h | 3 +
include/trace/events/migrate.h | 29 +++++++
mm/compaction.c | 8 +-
mm/migrate.c | 23 +++++-
mm/mlock.c | 142 ++++++++++++++++++++++++++++++++-
mm/rmap.c | 16 +++-
7 files changed, 216 insertions(+), 11 deletions(-)

--
2.43.0