Re: [PATCH] mm/list_lru: don't copy stale shrinker id from non-memcg-aware shrinkers
From: Michal Koutný
Date: Thu Sep 03 2026 - 05:31:01 EST
On Thu, Sep 03, 2026 at 12:06:53PM +0800, Qinyun Tan <qinyuntan@xxxxxxxxxxxxxxxxx> wrote:
> You're right, that sentence is imprecise - SHRINKER_NONSLAB shrinkers
> do register per-memcg under nokmem. What I meant is that on a system
> where no NONSLAB shrinker happens to register, shrinker_nr_max stays 0.
And ideally, with cgroup.memory=nokmem no slab-based code should call
set_shrinker_bit() with whatever shrinker_id.
> That said, I see the flag restoration and this patch as complementary
> rather than either-or:
Yes, it fixes your immediate issue and it is a prudent approach in
list_lru_init(). OTOH, with this fixup, we won't be able to learn about
shrinkers that are missing SHRINKER_NONSLAB.
> other MEMCG_AWARE-but-not-NONSLAB shrinkers
> (superblock, workingset shadow nodes) still take the fallback path
> under nokmem by design, and __list_lru_init() copying an unassigned
> id there is a landmine independent of the deferred split case. So I
> think this patch is still wanted as the generic fix, with the flag
> restoration on top for THP.
>
> (zswap might deserve the same NONSLAB treatment as THP, btw - its
> entries resolve the memcg from the folio's objcg, which is available
> regardless of nokmem.)
_That_ is an important point.
So that would need a fix too, and likely Fixes: b5ba474f3f518 ("zswap:
shrink zswap pool based on memory pressure").
(I'd have preferred if there weren't Fixes: 03375203e1da8 which honors
the SHRINKER_NONSLAB semantics and it only uncovered pre-existing
missing flags. Or keep that Fixes: but explain the relation to the other
commits. (To make it clear to backporters.))
> Would you like me to send a separate patch restoring SHRINKER_NONSLAB
> in thp_shrinker_init() (Fixes: fafaeceb89a5e)? Happy to do so if
> that works for you.
SHRINKER_MEMCG_AWARE are due to be checked for correct marking with
SHRINKER_NONSLAB. I can see that it is missing in: thp-deferred_split,
zswap-shrinker in the v7.3-rc1. (The shrinkers in nfs42xattr.c seem to
be slab-based so they're correct.)
The shrinkers mentioned in your original commit message: workingset
shadow nodes, superblock lrus are both slab-based, so systemd with only
those shouldn't be affected by this bug.
Thanks,
Michal
Attachment:
signature.asc
Description: PGP signature