[PATCH for-7.5 0/5] memcg: clean up memory.high enforcement
From: Shakeel Butt
Date: Sat Oct 10 2026 - 17:10:15 EST
This series cleans up memory.high enforcement and uses a worker for
kernel threads and remote charges.
Kernel threads never return to userspace to run deferred reclaim.
Reclaiming and sleeping during a charge can also delay work they do for
other tasks.
Remote charges can go to a different cgroup from the caller's mm, for
example through filesystem notifications or faults in another process's
memory. The high handler uses current->mm, so it can check the caller's
limits instead of the limits of the charged cgroup.
Use high_work to reclaim from the charged hierarchy in these cases.
mm_match_cgroup() identifies charges outside the current mm's cgroup
and its ancestors. Local user charges keep their current handling.
Skip queuing work from PF_MEMALLOC tasks. Reclaim can charge memory
itself, for example when zswap stores a page, and high_work must not
keep queuing itself from its own reclaim.
This is best effort. A fast allocator can keep usage well above
memory.high. The worker paths also skip memory.swap.high throttling
and its high-event reporting. The memory.max and memory.swap.max checks
stay the same.
The first patch moves enforcement into memcg_enforce_high(). The next
two add kernel thread and remote charge handling. The fourth adds the
reclaim guard. The last simplifies the scan and comments. The first
and last patches have no intended behavior change.
Based on next-20261009. Tested in an x86-64 VM with loop writes, threaded
NAPI, remote faults, notifications, and both vhost worker modes. The
remote tests kept same-cgroup and ancestor charges on the local path.
An incompressible zswap test queued high_work from its own reclaim 163
times without the guard.
Shakeel Butt (5):
memcg: move memory.high enforcement out of try_charge_memcg()
memcg: use high_work for kernel threads
memcg: use high_work for remote charges
memcg: avoid queuing high_work from reclaim
memcg: simplify high limit handling after a charge
mm/memcontrol.c | 136 +++++++++++++++++++++++++++---------------------
1 file changed, 77 insertions(+), 59 deletions(-)
base-commit: becb95e45ef0dda9ffb35156d909d3da7a2789c3
--
2.53.0-Meta