Re: [PATCH v6 31/33] mm: memcontrol: convert objcg to be per-memcg per-node type
From: Usama Arif
Date: Fri Mar 06 2026 - 15:29:49 EST
On Thu, 5 Mar 2026 19:52:49 +0800 Qi Zheng <qi.zheng@xxxxxxxxx> wrote:
> From: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
>
> Convert objcg to be per-memcg per-node type, so that when reparent LRU
> folios later, we can hold the lru lock at the node level, thus avoiding
> holding too many lru locks at once.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
> Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> ---
> include/linux/memcontrol.h | 23 +++++------
> include/linux/sched.h | 2 +-
> mm/memcontrol.c | 79 +++++++++++++++++++++++---------------
> 3 files changed, 62 insertions(+), 42 deletions(-)
>
[...]
> @@ -4087,7 +4100,13 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
> xa_store(&mem_cgroup_private_ids, memcg->id.id, memcg, GFP_KERNEL);
>
> return 0;
> -free_shrinker:
> +free_objcg:
> + for_each_node(nid) {
> + struct mem_cgroup_per_node *pn = memcg->nodeinfo[nid];
> +
> + if (pn && pn->orig_objcg)
> + obj_cgroup_put(pn->orig_objcg);
Is it possible that you might call obj_cgroup_put twice on the same cgroup?
If css_create fails, css_free_rwork_fn is queued, which ends up calling
mem_cgroup_css_free which calls obj_cgroup_put again?
Maybe adding pn->orig_objcg = NULL overhere after obj_cgroup_put
is enough to prevent the double put from causing issues?
> + }
> free_shrinker_info(memcg);
> offline_kmem:
> memcg_offline_kmem(memcg);
> --
> 2.20.1
>
>