Re: [PATCH] mm: memcg: use ratelimited stats flush in obj_cgroup_may_zswap()

From: Chengfeng Lin

Date: Sun Nov 15 2026 - 08:38:30 EST


Hi Joanne,

I tested the non-forced flush in our setup. It delivered PAGEOUT CPU
savings similar to those of the hierarchical per-CPU counter variant.

The only change in the non-forced variant was:

__mem_cgroup_flush_stats(memcg, true);
-> mem_cgroup_flush_stats(memcg);

Both variants used the same MM base, 2967f3ccdb5f, and the unchanged
reproducers attached to my previous mail: 32 MiB with one worker, and
256 MiB with eight workers. The finite memory.zswap.max remained 64 MiB;
compressed occupancy was about 18.75 MiB in the larger test, below the cap.
The hardware was the same i7-12700KF with microcode 0x3e.

I ran five separate boots: baseline, non-forced, baseline, counters,
baseline. Each boot had two warmups and nine measured program runs per
condition, including an unlimited control. Reductions below are relative
to the mean of each variant's two adjacent baselines:

Finite-limit PAGEOUT CPU Non-forced Counter variant
1 worker / 32 MiB 12.640 ms (-45.72%) 13.276 ms (-43.04%)
8 workers / 256 MiB 202.784 ms (-84.03%) 207.455 ms (-83.55%)

These are summed worker CPU times, not elapsed times. Whole-program CPU
reductions (non-forced / counters) were 22.57% / 20.97% with one worker
and 61.82% / 59.97% with eight.
The counter variant is the same hierarchical per-CPU adaptation tested in
my previous mail; it retains the existing rstat updates.

PAGEOUT CVs (non-forced / counters) were 4.65% / 4.33% with one worker
and 2.91% / 9.26% with eight. The maximum absolute PAGEOUT baseline drift
in these finite-limit comparisons was 1.69%. The small mean differences
do not establish that one variant is faster.

Separate instrumented admission runs also confirmed that non-forced does
not mean no flush: the limit check performed 53 / 818 actual rstat flushes
for one / eight workers, versus 8192 / 65536 with forced flushing and zero
with counters, while successful stores remained 8192 / 65536.

So the simpler change appears sufficient for the main benefit in this
below-cap workload.

Thanks,
Chengfeng