[RFC PATCH v2 0/1] mm: pcp->high is never decayed on isolated CPUs
From: Ionut Nechita
Date: Tue Dec 01 2026 - 08:56:58 EST
Hi,
On isolated CPUs, pcp->high can be raised by PCP auto-tuning but is
never lowered again, and the pages cached on those pcp lists are never
given back: vmstat_shepherd() skips isolated CPUs since commit
be5e015d107d, and decay_pcp_high() is only called from their
vmstat_update(). On a 64-CPU telco system (6.18-rt,
isolcpus=domain,nohz) this left about 28 GiB on the pcp lists after 8
days. The patch lets vmstat_shepherd() run decay_pcp_high() remotely for
isolated CPUs, under pcp->lock, only when auto-tuning raised pcp->high
there.
v1 was only build-tested; v2 adds a reproduction and measurements of the
interference on the isolated CPUs, done in QEMU/KVM (not on hardware
yet).
Changes in v2:
- Commit message: say which CPUs are affected. In current mainline
cpu_is_isolated() means isolated from the scheduler domains
(isolcpus=domain or an isolated cpuset partition); in older kernels
such as 6.12 and 6.18 it also covers nohz_full CPUs.
- Commit message: add the reproduction on v7.4-rc4.
- Initialize 'isolated' in vmstat_shepherd() (it is only assigned
inside scoped_guard()).
- decay_pcp_high(): keep READ_ONCE() for pcp->high_min and pcp->batch,
which pageset_update() changes without pcp->lock (Sashiko).
- decay_pcp_high(): evaluate the excess to drain again under pcp->lock
before each batch instead of draining the amount computed once: with
the lock dropped between batches the remote (isolated) CPU may
allocate from or drain its lists, and the stale amount could take
them below pcp->high, down to an empty list, taking zone->lock for
nothing on the remaining batches. The first batch is drained without
dropping the lock taken for the pcp->high update (Sashiko).
Test setup: v7.4-rc4-1030-g946d9ed1aa02 with and without this patch,
the same .config (x86_64 defconfig + PREEMPT_RT, NO_HZ_FULL, lockdep),
QEMU/KVM with 4 vCPUs and 2 GB, isolcpus=domain,managed_irq,1-3
nohz_full=1-3 rcu_nocbs=1-3. After boot, a task pinned to CPU 2 maps,
writes and unmaps 512 MiB of anonymous memory (MADV_NOHUGEPAGE) 20
times, then the system stays idle for 30 seconds; /proc/zoneinfo is
read every 5 seconds.
1) Pages left on CPU 2's pcp lists (summed over its zones):
after the churn after 30 s idle
without the patch 15170 (59 MiB) 15170 (59 MiB)
with the patch 14990 (59 MiB) 475 (1.9 MiB)
With the patch CPU 2 decays at the same rate as the housekeeping
CPU 0 (pcp->high minus 1/8 per second).
(Medians of 5 boots per kernel; every boot without the patch kept
all of it, every boot with the patch was back at high_min.)
2) Interference during the 30 s idle window, when the remote decay
runs (5 boots per kernel, ipi_send_cpu / ipi_send_cpumask
tracepoints, /proc/interrupts and /proc/softirqs deltas): the
isolated CPUs received the same interrupts and IPIs with and without
the patch (CPU 2: 15 function-call IPIs, nothing else), and CPU 2
received no tick.
3) Allocation latency on the isolated CPU while it is being decayed
remotely: each page fault of the churn above timed on CPU 2
(2.6M faults per boot, 5 boots per kernel alternating with the
other kernel on a quiet host, median of the 5; the timer read adds
~0.1-0.5 us):
p50 p99 p99.9 churn time
without the patch 2.11 us 9.98 us 31.2 us 9.94 s
with the patch 2.11 us 9.47 us 31.2 us 9.94 s
No difference within run-to-run noise.
4) vm.percpu_pagelist_high_fraction=128/256/512 (auto-tuning off)
bounds what CPU 2 keeps (3.8/1.9/1.0 MiB in this guest) with or
without the patch, but the churn took 1.4-2.3 times longer than with
auto-tuning, so it is a workaround rather than a fix.
The patch is based on the mm-new branch of akpm/mm.git (872ceec1e3ca,
v7.4-rc4-1266) and applies cleanly there. It was built, booted and
probed on mm-new as well, with the same result (CPU 2 back at high_min,
no extra IPIs); the measurements above were taken on the mainline
kernel of the test setup (v7.4-rc4-1030-g946d9ed1aa02), where it
applies unchanged.
Open questions, as in v1:
1. Is remote decay from vmstat_shepherd() acceptable for isolated
CPUs? It sends no IPI and takes the remote pcp->lock only after
auto-tuning raised pcp->high; an allocation on the isolated CPU
that races with it falls back to the zone lock through
pcp_spin_trylock(). The alternatives considered were decaying from
quiet_vmstat() (not possible on PREEMPT_RT, zone->lock sleeps) and
not auto-tuning on isolated CPUs.
2. decay_pcp_high() now takes pcp->lock for the pcp->high update on
the local vmstat_update() path too. Taking it only for remote
pagesets would leave a window when a CPU becomes isolated at run
time (cpuset) while its own vmstat_update() is still queued.
3. The NUMA remote pageset expiry in refresh_cpu_vm_stats() has the
same problem on isolated CPUs. It is not addressed here.
v1: https://lore.kernel.org/r/20261126134410.17447-1-ionut.nechita@xxxxxxxxxxxxx
Thanks,
Ionut
Ionut Nechita (1):
mm/vmstat: decay pcp->high of isolated CPUs from vmstat_shepherd
mm/page_alloc.c | 64 ++++++++++++++++++++++++++++++++++++++++++-------
mm/page_alloc.h | 1 +
mm/vmstat.c | 14 +++++++----
3 files changed, 66 insertions(+), 13 deletions(-)
base-commit: 872ceec1e3caf227655a58f7407a9c8493dcf56f
--
2.56.1