Re: [PATCH RFC v2 6/6] mm/memcg: filter out reparented memcgs got from memcgid

From: Bingfang Guo

Date: Sat Sep 05 2026 - 15:48:47 EST


On Sat, Sep 05, 2026 at 08:18:03PM +0800, Muchun Song wrote:
>
>
> > On Sep 1, 2026, at 16:58, Bingfang Guo via B4 Relay <devnull+bingfangguo.tencent.com@xxxxxxxxxx> wrote:
> >
> > From: Bingfang Guo <bingfangguo@xxxxxxxxxxx>
> >
> > mem_cgroup_from_private_id() looks up the objcg that owns the id and
> > returns the objcg's current memcg. After reparenting, that memcg can
> > differ from the one the id originally belonged to.
> >
> > Callers such as the list lru and workingset refault code expect to get
> > back exactly the memcg referred to by the memcgid, so check that the
> > returned memcg still owns the id and return NULL otherwise. In this
> > case, make list_lru just skip and workingset tests use the root (as the
> > comments said in workingset.c:460).
> >
> > Signed-off-by: Bingfang Guo <bingfangguo@xxxxxxxxxxx>
>
> We should move this patch earlier to avoid introducing the problem first
> and then fixing it later.

OK. I will keep that in mind.

Regards,
Bingfang

>
> Muchun,
> Thanks.
>