Re: [RFC PATCH 06/10] memcg: do obj_cgroup_put inside drain_obj_stock

From: Vlastimil Babka
Date: Fri Mar 14 2025 - 06:17:57 EST


On 3/14/25 07:15, Shakeel Butt wrote:
> Previously we could not call obj_cgroup_put() inside the local lock
> because on the put on the last reference, the release function
> obj_cgroup_release() may try to re-acquire the local lock. However that
> chain has been broken. Now simply do obj_cgroup_put() inside
> drain_obj_stock() instead of returning the old objcg.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>

Hm is this really safe? I can see obj_cgroup_release() doing
percpu_ref_exit() -> kfree(), do we have guaranteed that allocation won't be
also in a kmemcg and recurse?