From: Waiman Long <longman@redhat.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: update parent subparts cpumask while holding css refcnt
Date: Sat, 1 Jul 2023 19:46:37 -0400 [thread overview]
Message-ID: <a6c55b82-71eb-ad18-e4b2-d62f1102a0e4@redhat.com> (raw)
In-Reply-To: <9244d968-b25a-066f-2ff3-1281bf03983e@redhat.com>
On 7/1/23 19:38, Waiman Long wrote:
> On 7/1/23 02:50, Miaohe Lin wrote:
>> update_parent_subparts_cpumask() is called outside RCU read-side
>> critical
>> section without holding extra css refcnt of cp. In theroy, cp could be
>> freed at any time. Holding extra css refcnt to ensure cp is valid while
>> updating parent subparts cpumask.
>>
>> Fixes: d7c8142d5a55 ("cgroup/cpuset: Make partition invalid if
>> cpumask change violates exclusivity rule")
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>> kernel/cgroup/cpuset.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 58e6f18f01c1..632a9986d5de 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -1806,9 +1806,12 @@ static int update_cpumask(struct cpuset *cs,
>> struct cpuset *trialcs,
>> cpuset_for_each_child(cp, css, parent)
>> if (is_partition_valid(cp) &&
>> cpumask_intersects(trialcs->cpus_allowed,
>> cp->cpus_allowed)) {
>> + if (!css_tryget_online(&cp->css))
>> + continue;
>> rcu_read_unlock();
>> update_parent_subparts_cpumask(cp,
>> partcmd_invalidate, NULL, &tmp);
>> rcu_read_lock();
>> + css_put(&cp->css);
>> }
>> rcu_read_unlock();
>> retval = 0;
>
> Thanks for finding that. It looks good to me.
>
> Reviewed-by: Waiman Long <longman@redhat.com>
Though, I will say that an offline cpuset cannot be a valid partition
root. So it is not really a problem. For correctness sake and
consistency with other similar code, I am in favor of getting it merged.
Cheers,
Longman
next prev parent reply other threads:[~2023-07-01 23:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-01 6:50 Miaohe Lin
2023-07-01 23:38 ` Waiman Long
2023-07-01 23:46 ` Waiman Long [this message]
2023-07-03 2:58 ` Miaohe Lin
2023-07-03 19:18 ` Tejun Heo
2023-07-10 15:11 ` Michal Koutný
2023-07-10 15:40 ` Waiman Long
2023-07-10 15:51 ` Michal Koutný
2023-07-11 2:52 ` Miaohe Lin
2023-07-11 11:52 ` Michal Koutný
2023-07-12 1:56 ` Miaohe Lin
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=a6c55b82-71eb-ad18-e4b2-d62f1102a0e4@redhat.com \
--to=longman@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.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
all inboxes | Powered by JetHome®