From: Shakeel Butt <shakeel.butt@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Chinner <david@fromorbit.com>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Qi Zheng <qi.zheng@linux.dev>,
Meta kernel team <kernel-team@meta.com>,
linux-mm@kvack.org, Chris Mason <mason@kernel.org>
Subject: Re: [PATCH] mm: list_lru: don't use a new memcg's lists for an offline memcg
Date: Thu, 12 Nov 2026 18:37:10 -0800 [thread overview]
Message-ID: <avZ3rcGiLnWS4qUq@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-211977@kernel.org>
On Fri, Nov 13, 2026 at 12:15:11AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] mm: list_lru: missing mlru->memcg check in
> memcg_list_lru_allocated()
> --
>
> commit d213b82b7b4ca4978c858df10a2a8cdea14626e4
> Author: Shakeel Butt <shakeel.butt@linux.dev>
>
> mm: list_lru: don't use a new memcg's lists for an offline memcg
>
> This commit records the owning memcg in struct list_lru_memcg and checks it
> in list_lru_from_memcg() so that an offline memcg whose kmemcg_id was reused
> does not use the new memcg's lists.
>
> > diff --git a/mm/list_lru.c b/mm/list_lru.c
> > index d1d256822ccc7..937dbf239c9d4 100644
> > --- a/mm/list_lru.c
> > +++ b/mm/list_lru.c
> > @@ -72,12 +72,15 @@ static int lru_shrinker_id(struct list_lru *lru)
> > }
> >
> > static inline struct list_lru_one *
> > -list_lru_from_memcg_idx(struct list_lru *lru, int nid, int idx)
> > +list_lru_from_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg)
> > {
> > + int idx = memcg_kmem_id(memcg);
> > +
> > if (list_lru_memcg_aware(lru) && idx >= 0) {
> > struct list_lru_memcg *mlru = xa_load(&lru->xa, idx);
> >
> > - return mlru ? &mlru->node[nid] : NULL;
> > + /* Lists at a reused index belong to another memcg. */
> > + return mlru && mlru->memcg == memcg ? &mlru->node[nid] : NULL;
> > }
> > return &lru->node[nid].lru;
> > }
>
> [ ... ]
>
> > @@ -602,6 +604,8 @@ static int __memcg_list_lru_alloc(struct mem_cgroup *memcg,
> > if (!mlru)
> > return -ENOMEM;
> > }
> > + /* Set before the lists are published, and never changed after. */
> > + mlru->memcg = pos;
> > xas_set(&xas, pos->kmemcg_id);
> > do {
> > xas_lock_irqsave(&xas, flags);
>
> [Severity: High]
> Does memcg_list_lru_allocated() also need to check mlru->memcg == memcg?
Yes this is correct and Andrew already have a fix for this.
prev parent reply other threads:[~2026-11-13 2:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 22:12 [PATCH] mm: list_lru: don't use a new memcg's lists for an offline memcg Shakeel Butt
2026-11-13 0:15 ` sashiko-bot
2026-11-13 2:37 ` Shakeel Butt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avZ3rcGiLnWS4qUq@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.