[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53486caa-8ca7-78f5-71ac-d5692b482c94@huawei.com>
Date: Mon, 3 Jul 2023 10:58:19 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Waiman Long <longman@...hat.com>
CC: <cgroups@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<tj@...nel.org>, <hannes@...xchg.org>, <lizefan.x@...edance.com>
Subject: Re: [PATCH] cgroup/cpuset: update parent subparts cpumask while
holding css refcnt
On 2023/7/2 7:46, Waiman Long wrote:
> 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@...wei.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@...hat.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.
Yes, cpuset_mutex will prevent cpuset from being offline while update cpumask. And as you mentioned, this patch makes code more consistency at least.
Thanks for your review and comment.
Powered by blists - more mailing lists