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>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
Sun Shaojie <sunshaojie@kylinos.cn>
Subject: Re: [cgroup/for-6.20 PATCH v2 2/4] cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier()
Date: Sun, 4 Jan 2026 16:25:20 -0500 [thread overview]
Message-ID: <f8539426-92b0-42f3-99c4-70962c2db96d@redhat.com> (raw)
In-Reply-To: <758f42df-52c2-4660-8ef7-1cbacb9323d2@huaweicloud.com>
On 1/3/26 9:48 PM, Chen Ridong wrote:
>
> On 2026/1/2 3:15, Waiman Long wrote:
>> Since commit f62a5d39368e ("cgroup/cpuset: Remove remote_partition_check()
>> & make update_cpumasks_hier() handle remote partition"), the
>> compute_effective_exclusive_cpumask() helper was extended to
>> strip exclusive CPUs from siblings when computing effective_xcpus
>> (cpuset.cpus.exclusive.effective). This helper was later renamed to
>> compute_excpus() in commit 86bbbd1f33ab ("cpuset: Refactor exclusive
>> CPU mask computation logic").
>>
>> This helper is supposed to be used consistently to compute
>> effective_xcpus. However, there is an exception within the callback
>> critical section in update_cpumasks_hier() when exclusive_cpus of a
>> valid partition root is empty. This can cause effective_xcpus value to
>> differ depending on where exactly it is last computed. Fix this by using
>> compute_excpus() in this case to give a consistent result.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> kernel/cgroup/cpuset.c | 14 +++++---------
>> 1 file changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index da2b3b51630e..37d118a9ad4d 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -2168,17 +2168,13 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>> spin_lock_irq(&callback_lock);
>> cpumask_copy(cp->effective_cpus, tmp->new_cpus);
>> cp->partition_root_state = new_prs;
>> - if (!cpumask_empty(cp->exclusive_cpus) && (cp != cs))
>> - compute_excpus(cp, cp->effective_xcpus);
>> -
>> /*
>> - * Make sure effective_xcpus is properly set for a valid
>> - * partition root.
>> + * Need to compute effective_xcpus if either exclusive_cpus
>> + * is non-empty or it is a valid partition root.
>> */
>> - if ((new_prs > 0) && cpumask_empty(cp->exclusive_cpus))
>> - cpumask_and(cp->effective_xcpus,
>> - cp->cpus_allowed, parent->effective_xcpus);
>> - else if (new_prs < 0)
>> + if ((new_prs > 0) || !cpumask_empty(cp->exclusive_cpus))
>> + compute_excpus(cp, cp->effective_xcpus);
>> + if (new_prs < 0)
>> reset_partition_data(cp);
>> spin_unlock_irq(&callback_lock);
>>
> The code resets partition data only for new_prs < 0. My understanding is that a partition is invalid
> when new_prs <= 0. Shouldn't reset_partition_data() also be called when new_prs = 0? Is there a
> specific reason to skip the reset in that case?
update_cpumasks_hier() is called when changes in a cpuset or hotplug
affects other cpusets in the hierarchy. With respect to changes in
partition state, it is either from valid to invalid or vice versa. It
will not change from a valid partition to member. The only way new_prs =
0 is when old_prs = 0. Even if the affected cpuset is processed again in
update_cpumask_hier(), any state change from valid partition to member
(update_prstate()), reset_partition_data() should have been called
there. That is why we only care about when new_prs != 0.
The code isn't wrong here. However I can change the condition to
(new_prs <= 0) if it makes it easier to understand.
Cheers,
Longman
next prev parent reply other threads:[~2026-01-04 21:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-01 19:15 [cgroup/for-6.20 PATCH v2 0/4] cgroup/cpuset: Don't invalidate sibling partitions on cpuset.cpus conflict Waiman Long
2026-01-01 19:15 ` [cgroup/for-6.20 PATCH v2 1/4] cgroup/cpuset: Streamline rm_siblings_excl_cpus() Waiman Long
2026-01-04 1:55 ` Chen Ridong
2026-01-01 19:15 ` [cgroup/for-6.20 PATCH v2 2/4] cgroup/cpuset: Consistently compute effective_xcpus in update_cpumasks_hier() Waiman Long
2026-01-04 2:48 ` Chen Ridong
2026-01-04 21:25 ` Waiman Long [this message]
2026-01-05 1:15 ` Chen Ridong
2026-01-05 3:50 ` Waiman Long
2026-01-05 3:58 ` Chen Ridong
2026-01-05 4:06 ` Waiman Long
2026-01-05 6:29 ` Chen Ridong
2026-01-09 20:15 ` Waiman Long
2026-01-12 1:10 ` Chen Ridong
2026-01-01 19:15 ` [cgroup/for-6.20 PATCH v2 3/4] cgroup/cpuset: Don't fail cpuset.cpus change in v2 Waiman Long
2026-01-04 7:09 ` Chen Ridong
2026-01-04 21:48 ` Waiman Long
2026-01-05 1:35 ` Chen Ridong
2026-01-05 3:59 ` Waiman Long
2026-01-05 7:00 ` Chen Ridong
2026-01-09 4:14 ` Waiman Long
2026-01-08 19:03 ` Michal Koutný
2026-01-01 19:15 ` [cgroup/for-6.20 PATCH v2 4/4] cgroup/cpuset: Don't invalidate sibling partitions on cpuset.cpus conflict Waiman Long
2026-01-04 7:53 ` Chen Ridong
2026-01-04 22:26 ` Waiman Long
2026-01-08 19:04 ` Michal Koutný
2026-01-09 1:30 ` Chen Ridong
2026-01-09 16:12 ` Michal Koutný
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=f8539426-92b0-42f3-99c4-70962c2db96d@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=corbet@lwn.net \
--cc=hannes@cmpxchg.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=shuah@kernel.org \
--cc=sunshaojie@kylinos.cn \
--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