Re: [PATCH 3/5] mm/mglru: cache the last memcg node, make tail insertion constant time

From: Max Kellermann

Date: Mon Nov 02 2026 - 03:31:44 EST


On Sun, Nov 1, 2026 at 10:50 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> So. Can someone please propose a nice simple quick-fix which we can
> backport into the -stable stream while we work on the larger
> rearchitecting projects?
>
> I think that might be Max's [5/5]? Max, do you know whether that patch
> alone will fix up 6.18.x, or do we also need to addressed that lengthy
> spinlocked tail insertion?
>
> If you think [5/5] is sufficient for -stable then please propose that as
> a standalone cc:stable thing then we can look at the broader changes on
> top.

Depends on your definition of "sufficient". I guess [5/5] will make
the symptom go away (the stalls), which is a good thing, but I see
this as a minor incremental improvement that doesn't solve any real
problem.

The real problem is the degenerate performance due to a silly linked
list insertion algorithm (traversing the whole list each time). So
with just [5/5], you'd still have hanging processes and abysmal
performance, no progress anywhere, but nothing would be logged. On the
positive side, not stalling RCU would at least not pull the rest of
the kernel down with it...

I repeated my benchmark, this time with Linux 6.18.60 and an isolated
run with just [5/5]:

No patches Only 5/5 All patches
Requests/s 5.28 3.20 50.91
Mean latency (ms) 1494 2463 154
Max latency (ms) 3932 10467 1685
CPU time/request (ms) 1494 2452 153

Patch [5/5] does not improve the underlying performance problem,
there's even a regression in this run which might be noise.
(My micro-benchmark does not reproduce RCU stalls and thus does not
prove the RCU stalls are gone.)

If you believe [5/5] should alone should be a stable bugfix, I'll
resubmit it to stable@.

--
Max Kellermann
Principal Architect
Hosting Technology

cm4all | Im Mediapark 6a | 50670 Köln | Germany
General information about the company can be found here:
https://www.cm4all.com/impressum
A member of the IONOS Group