On Mon, Apr 12, 2021 at 11:58 PM Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote: > > The obj_cgroup_release() and memcg_reparent_objcgs() are serialized by > the css_set_lock. We do not need to care about objcg->memcg being > released in the process of obj_cgroup_release(). So there is no need > to pin memcg before releasing objcg. Remove those pinning logic to > simplfy the code. > > There are only two places that modifies the objcg->memcg. One is the > initialization to objcg->memcg in the memcg_online_kmem(), another > is objcgs reparenting in the memcg_reparent_objcgs(). It is also > impossible for the two to run in parallel. So xchg() is unnecessary > and it is enough to use WRITE_ONCE(). > > Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> > Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx>