From: Waiman Long <llong@redhat.com>
To: "Chen Ridong" <chenridong@huaweicloud.com>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Ingo Molnar <mingo@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>
Subject: Re: [PATCH 2/3] cgroup/cpuset.c: Fix a partition error with CPU hotplug
Date: Thu, 7 Aug 2025 09:54:54 -0400 [thread overview]
Message-ID: <2870d179-a2db-44ee-9183-11efe446ebd9@redhat.com> (raw)
In-Reply-To: <38800495-464f-4bbf-b605-9a6b8d2b4c11@huaweicloud.com>
On 8/6/25 10:44 PM, Chen Ridong wrote:
>
> On 2025/8/7 1:24, Waiman Long wrote:
>> It was found during testing that an invalid leaf partition with an
>> empty effective exclusive CPU list can become a valid empty partition
>> with no CPU afer an offline/online operation of an unrelated CPU. An
>> empty partition root is allowed in the special case that it has no
>> task in its cgroup and has distributed out all its CPUs to its child
>> partitions. That is certainly not the case here.
>>
>> The problem is in the cpumask_subsets() test in the hotplug case
>> (update with no new mask) of update_parent_effective_cpumask() as it
>> also returns true if the effective exclusive CPU list is empty. Fix that
>> by addding the cpumask_empty() test to root out this exception case.
>> Also add the cpumask_empty() test in cpuset_hotplug_update_tasks()
>> to avoid calling update_parent_effective_cpumask() for this special case.
>>
>> Fixes: 0c7f293efc87 ("cgroup/cpuset: Add cpuset.cpus.exclusive.effective for v2")
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/cgroup/cpuset.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index bf149246e001..d993e058a663 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -1843,7 +1843,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
>> if (is_partition_valid(cs))
>> adding = cpumask_and(tmp->addmask,
>> xcpus, parent->effective_xcpus);
>> - } else if (is_partition_invalid(cs) &&
>> + } else if (is_partition_invalid(cs) && !cpumask_empty(xcpus) &&
>> cpumask_subset(xcpus, parent->effective_xcpus)) {
>> struct cgroup_subsys_state *css;
>> struct cpuset *child;
> This path looks good to me.
>
> However, I found the update_parent_effective_cpumask function a bit difficult to follow due to its
> complexity.
>
> To improve readability, could we refactor the partcmd_enable, partcmd_disable, partcmd_update and
> partcmd_invalidate logic into separate, well-defined function blocks? I'd be happy to take
> ownership of this refactoring work if you agree with the approach.
I agree that the code can be a bit hard to read. You are more than
welcome to improve the readability of the code if you have time.
Cheers,
Longman
next prev parent reply other threads:[~2025-08-07 13:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 17:24 [PATCH 0/3] cgroup/cpuset: Miscellaneous fixes and cleanup Waiman Long
2025-08-06 17:24 ` [PATCH 1/3] cgroup/cpuset: Use static_branch_enable_cpuslocked() on cpusets_insane_config_key Waiman Long
2025-08-07 13:15 ` Juri Lelli
2025-08-07 13:47 ` Waiman Long
2025-08-06 17:24 ` [PATCH 2/3] cgroup/cpuset.c: Fix a partition error with CPU hotplug Waiman Long
2025-08-06 17:30 ` Waiman Long
2025-08-07 2:44 ` Chen Ridong
2025-08-07 13:54 ` Waiman Long [this message]
2025-08-06 17:24 ` [PATCH 3/3] cgroup/cpuset: Remove the unnecessary css_get/put() in cpuset_partition_write() Waiman Long
2025-08-07 11:25 ` Michal Koutný
2025-08-09 18:44 ` [PATCH 0/3] cgroup/cpuset: Miscellaneous fixes and cleanup Tejun Heo
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=2870d179-a2db-44ee-9183-11efe446ebd9@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--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).