Re: [PATCH v2 1/4] mm: memcontrol: drop kmemcg_id and use the memcg ID for list_lru indexing
From: Qinyun Tan
Date: Thu Sep 10 2026 - 03:41:34 EST
On 9/10/26 2:21 AM, Johannes Weiner wrote:
> On Mon, Sep 07, 2026 at 07:01:08PM +0800, Qinyun Tan wrote:
>
> This is a private ID with lifetime only guaranteed for online
> groups. Reparenting happens right before it dies at offlining right
> now, but this is not a great dependency to have.
>
> Use mem_cgroup_id() instead and just get rid of that helper.
>
Hi Johannes,
Thanks for the review.
Right, the copy of the private ID carried exactly that ordering
dependency, and the cgroup ID removes it cleanly. mem_cgroup_id()
it is.
> Both of these functions do very little now and the asymmetry you're
> adding on the mem_cgroup_kmem_disabled() check looks odd. Please just
> inline them into mem_cgroup_css_online()/offline():
>
> onlining:
> if (!mem_cgroup_kmem_disabled() && likely(!mem_cgroup_is_root()))
> static_branch_enable(&memcg_kmem_online_key);
>
> offlining:
> memcg_reparent_list_lrus(memcg, parent);
>
> The root check is unnecessary because roots are not destroyed. But if
> you'd rather not make that change here, keep the root check, and leave
> its removal to a separate cleanup patch, that's fine too.
>
That makes sense. I'll send a v3 with these changes.
Thanks again,
Qinyun Tan