From: Shakeel Butt <shakeel.butt@linux.dev>
To: Muchun Song <muchun.song@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
Michal Koutny <mkoutny@suse.com>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Meta kernel team <kernel-team@meta.com>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] memcg: free the private ID of a memcg that never comes online
Date: Mon, 23 Nov 2026 20:33:33 -0800 [thread overview]
Message-ID: <awUTKy9tx8nWJgXf@linux.dev> (raw)
In-Reply-To: <F39B4A81-BB17-4C5D-851E-2740EBBBBA8B@linux.dev>
On Tue, Nov 24, 2026 at 10:50:00AM +0800, Muchun Song wrote:
>
>
> > On Nov 24, 2026, at 08:04, Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
[...]
>
> The leak analysis and the fix look correct to me. However, using
> CSS_RELEASED here makes the private ID cleanup depend on a generic CSS
> teardown state, and adds an accessor solely for this failure path.
>
> The private ID is not needed until mem_cgroup_css_online(), so could we
> instead reserve it at the beginning of that callback? Failures in
> css_create() before ->css_online() would then never own a private ID,
> while failures after the reservation would continue to use the existing
> mem_cgroup_private_id_remove() cleanup.
>
> This would also make the private ID lifecycle more explicit: reserve and
> publish it during online, then drop the initial reference during offline.
> It would avoid both the new css_is_released() helper and special handling
> in mem_cgroup_css_free().
Thanks Muchun. Nothing needs the private ID before ->css_online(), so
reserving it there would work. But it moves the out-of-IDs failure from
->css_alloc() to ->css_online(). By then css_create() has linked the
css into the parent's children list and css_idr, so mem_cgroup_iter()
can css_tryget() it and cache it in iter->position. A css that fails
online is freed without ->css_released(), so
invalidate_reclaim_iterators() never runs, and the free does not wait
for those references. Today memcg's ->css_online() fails only when a
small allocation fails. With the move, every mkdir on a system that is
out of IDs would take that path. I would rather keep failing in
->css_alloc(), before anything is visible.
To drop the CSS_RELEASED dependency, I can test the ID's own state:
!memcg->private_id_objcg means the ID was never published and the memcg
still owns the reservation. Let me know if that works for you.
next prev parent reply other threads:[~2026-11-24 4:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 0:04 Shakeel Butt
2026-11-24 0:54 ` Andrew Morton
2026-11-24 1:09 ` Shakeel Butt
2026-11-24 2:50 ` Muchun Song
2026-11-24 4:33 ` Shakeel Butt [this message]
2026-11-24 4:52 ` Muchun Song
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=awUTKy9tx8nWJgXf@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.kernel.org \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®