Re: [PATCH cgroup/for-next 1/3] cgroup: remove redundancy online_cnt
From: Michal Koutný
Date: Tue Aug 26 2025 - 10:36:14 EST
Hello Ridong.
On Tue, Aug 26, 2025 at 03:40:20AM +0000, Chen Ridong <chenridong@xxxxxxxxxxxxxxx> wrote:
> @@ -5949,7 +5944,7 @@ static void css_killed_work_fn(struct work_struct *work)
> css_put(css);
> /* @css can't go away while we're holding cgroup_mutex */
> css = css->parent;
> - } while (css && atomic_dec_and_test(&css->online_cnt));
> + } while (css && css_is_dying(css) && !css->nr_descendants);
Here it's OK...
>
> cgroup_unlock();
> }
> @@ -5960,7 +5955,7 @@ static void css_killed_ref_fn(struct percpu_ref *ref)
> struct cgroup_subsys_state *css =
> container_of(ref, struct cgroup_subsys_state, refcnt);
>
> - if (atomic_dec_and_test(&css->online_cnt)) {
> + if (!css->nr_descendants) {
> INIT_WORK(&css->destroy_work, css_killed_work_fn);
> queue_work(cgroup_offline_wq, &css->destroy_work);
> }
... but here in percpu_ref's confirm callback you're accessing
nr_descendants without cgroup_mutex where the atomic would have
prevented the data race.
Also the semantics of online_cnt and nr_descendants is slightly
different -- killed vs offlined. Or can you add a description why
they're same (after workqueue split)?
Thanks,
Michal
Attachment:
signature.asc
Description: PGP signature