From: "Michal Koutný" <mkoutny@suse.com>
To: Chen Ridong <chenridong@huaweicloud.com>
Cc: tj@kernel.org, hannes@cmpxchg.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, lujialin4@huawei.com,
chenridong@huawei.com
Subject: Re: [PATCH cgroup/for-next 1/3] cgroup: remove redundancy online_cnt
Date: Tue, 26 Aug 2025 16:14:47 +0200 [thread overview]
Message-ID: <zumtn2pez376u2xacibdd6eueeueh6ole5w6pqbgccg2bj7fgd@o2szr644a3om> (raw)
In-Reply-To: <20250826034022.1736249-2-chenridong@huaweicloud.com>
[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]
Hello Ridong.
On Tue, Aug 26, 2025 at 03:40:20AM +0000, Chen Ridong <chenridong@huaweicloud.com> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
next prev parent reply other threads:[~2025-08-26 14:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 3:40 [PATCH cgroup/for-next 0/3] Improve clarity of cgroup destruction process Chen Ridong
2025-08-26 3:40 ` [PATCH cgroup/for-next 1/3] cgroup: remove redundancy online_cnt Chen Ridong
2025-08-26 14:14 ` Michal Koutný [this message]
2025-08-27 0:54 ` Chen Ridong
2025-08-27 0:59 ` Chen Ridong
2025-08-26 3:40 ` [PATCH cgroup/for-next 2/3] cgroup: add css_free helper Chen Ridong
2025-08-26 3:40 ` [PATCH cgroup/for-next 3/3] cgroup: rename css offline related functions Chen Ridong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=zumtn2pez376u2xacibdd6eueeueh6ole5w6pqbgccg2bj7fgd@o2szr644a3om \
--to=mkoutny@suse.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lujialin4@huawei.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).