Skip to content

mm: process_mrelease: expedite clean file folio reclaim and add auto-kill

Minchan Kim linux-mm linux-s390 lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 48 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm: process_mrelease: expedite clean file folio reclaim via mmu_gatherarch/s390/include/asm/tlb.h include/linux/swap.h mm/mmu_gather.c +2 more+49 -3310 replies
2/3mm: process_mrelease: skip LRU movement for exclusive file foliosmm/memory.c+12 -126 replies
3/3mm: process_mrelease: introduce PROCESS_MRELEASE_REAP_KILL flaginclude/uapi/linux/mman.h mm/oom_kill.c+43 -1712 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchSuren Baghdasaryan
1/3
2/3
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/3] mm: process_mrelease: expedite clean file folio reclaim and add auto-kill

From: Minchan Kim <[email protected]>

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/[email protected]/)
- 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(-)
Signature · 1 line
2.54.0.rc1.555.g9c883467ad-goog