[PATCH v1 0/3] mm: process_mrelease: expedite clean file folio reclaim and add auto-kill
From: Minchan Kim
Date: Tue Apr 21 2026 - 19:02:55 EST
From: Minchan Kim <minchan@xxxxxxxxxx>
This is v1 of the patch series to expedite clean file folio reclamation in
process_mrelease() and introduce an auto-kill flag to close race windows.
Currently, process_mrelease() unmaps pages but file-backed pages stay in
the pagecache, relying on standard memory reclaim to eventually free them.
This delays memory recovery in memory pressure scenarios (e.g., Android's
LMKD), leading to redundant kills of background apps. Also, the requirement
for userspace to send SIGKILL prior to process_mrelease() introduces a
race window where the victim task clears its ->mm before the reaper can
act, failing the syscall with -ESRCH and delaying reclamation due to
arbitrary reference counts (e.g., reading /proc/<pid>/cmdline).
Summary of v1 changes since last RFC
(https://lore.kernel.org/linux-mm/20260413223948.556351-1-minchan@xxxxxxxxxx/)
- Patch 1:
- Unified free_pages_and_caches() in mm/swap.c to handle both CONFIG_SWAP
and !CONFIG_SWAP
- Clean up description - David
- Patch 2:
- Used !folio_maybe_mapped_shared(folio) instead of folio_mapcount - David
- Patch 3:
- Used mmget() instead of mmgrab() to ensure that memory reclamation is
performed synchronously and deterministically by the reaper, avoiding
delays caused by non-deterministic scheduling of the victim task.
- Dropped the custom KILL_MRELEASE signal code and modifications to
siginfo.h and signal.c. Instead, use standard kill_pid(..., 0).
Minchan Kim (3):
mm: process_mrelease: expedite clean file folio reclaim via mmu_gather
mm: process_mrelease: skip LRU movement for exclusive file folios
mm: process_mrelease: introduce PROCESS_MRELEASE_REAP_KILL flag
arch/s390/include/asm/tlb.h | 2 +-
include/linux/swap.h | 5 ++--
include/uapi/linux/mman.h | 4 +++
mm/memory.c | 13 ++++++++-
mm/mmu_gather.c | 7 +++--
mm/oom_kill.c | 56 ++++++++++++++++++++++++++-----------
mm/swap.c | 42 ++++++++++++++++++++++++++++
mm/swap_state.c | 26 -----------------
8 files changed, 104 insertions(+), 51 deletions(-)
--
2.54.0.rc1.555.g9c883467ad-goog