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

From: Max Kellermann

Date: Mon Nov 16 2026 - 03:07:51 EST


On Sun, Nov 15, 2026 at 9:32 AM Barry Song <baohua@xxxxxxxxxx> wrote:
> > For me, it is not entirely clear if a stable backport is really
> > necessary (thus I did not Cc stable). It's not a bug; just awful
> > performance when you have thousands of memcgs, but few people have
> > that. But that's up for you to decide.
>
> Okay, thanks!
>
> I guess we can only reproduce the soft lockup with thousands of
> memcgs being rapidly rotated by artificial test scripts? In real-world
> scenarios, would this be more likely to manifest as a performance issue
> rather than a soft lockup?
>
> If so, let's focus on upstream mainline development first.

I did have soft lockups / RCU stalls on a production server; real
workload, no artificial test script. The workload is ten thousands of
containers - it's web hosting, and each Apache/PHP/... process lives
in a separate container (cgroup).

> > > > + if (at_head || !last)
> > > > hlist_nulls_add_head_rcu(&lrugen->list, head);
> > >
> > > Do we still need at_head now that MEMCG_LRU_OLD has been removed?
> >
> > Yes, for the "!last" case. This is, unfortunately, a special case.
> > If you prefer, we could move this special-casing to the hlist_nulls
> > API so callers need not be aware of it.
>
> I mean, you might not need `at_head` at all if you rebase your code
> onto either mm-new or mm-unstable.

True. I did already rebase, but did not post v3 yet - `at_head` is
indeed gone, but as I said, the "!last" check remains and means the
code doesn't get any simpler by the `at_head` removal.

I'll post the rebased v3 today.

--
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