From: Ridong Chen <ridong.chen@linux.dev>
To: "Waiman Long" <longman@redhat.com>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shuah Khan" <shuah@kernel.org>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Guopeng Zhang <guopeng.zhang@linux.dev>,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH-next v4 2/6] cgroup/cpuset: excpus parameter of remote_cpus_update() must have at least 1 active CPU
Date: Mon, 16 Nov 2026 15:37:30 +0800 [thread overview]
Message-ID: <8015ad75-0e4d-4928-8e56-8a495d752468@linux.dev> (raw)
In-Reply-To: <eb3fd5e1-aafe-4bbd-a9ca-afcdb1554fdb@redhat.com>
On 11/16/2026 11:34 AM, Waiman Long wrote:
> On 11/15/26 10:07 PM, Ridong Chen wrote:
>>
>>
>> On 11/16/2026 9:23 AM, Waiman Long wrote:
>>> It is reported that remote_cpus_update() fails to invalidate a
>>> populated remote partition when an ancestor cgroup update reduces its
>>> effective_xcpus mask to only offline CPUs.
>>>
>>> When update_cpumasks_hier() updates a descendant remote partition, it
>>> passes the new effective_xcpus mask (excpus) to remote_cpus_update().
>>> Because excpus still contains offline CPUs, cpumask_empty(excpus) is false
>>> and remote_cpus_update() only checks tasks_nocpu_error() when adding CPUs.
>>>
>>> With the partition left valid, update_cpumasks_hier() computes an empty
>>> effective_cpus mask and jumps to get_css. The populated partition stays
>>> valid with no effective CPUs instead of inheriting its parent's CPUs,
>>> and its tasks remain affine to the online CPUs returned to top_cpuset.
>>>
>>> Fix it by invalidating the remote partition if there is no active CPU
>>> available in the given excpus parameter.
>>>
>>> Reported-by: Sashiko <sashiko-bot@kernel.org>
>>> Link: https://sashiko.dev/#/bug/linux-936b7155-f652-4146-a4ab-ec48fd392a1d
>>> Signed-off-by: Waiman Long <longman@redhat.com>
>>> ---
>>> kernel/cgroup/cpuset.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>>> index 631fb449cef8..195d4e3a283c 100644
>>> --- a/kernel/cgroup/cpuset.c
>>> +++ b/kernel/cgroup/cpuset.c
>>> @@ -1810,7 +1810,8 @@ static void remote_cpus_update(struct cpuset *cs,
>>> struct cpumask *xcpus,
>>> WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus));
>>> - if (cpumask_empty(excpus)) {
>>> + /* New effective_xcpus must have at least one active CPU */
>>> + if (!cpumask_intersects(excpus, cpu_active_mask)) {
>>> WRITE_ONCE(cs->prs_err, PERR_CPUSEMPTY);
>>> goto invalidate;
>>> }
>>
>> This also invalidates a remote partition with no task whose excpus
>> only has offline CPUs. According to cgroup-v2.rst, such a partition
>> is valid: cpuset.cpus.exclusive.effective may contain offline CPUs,
>> and cpuset.cpus.effective can be empty if there is no task in the
>> partition. The hotplug path and tasks_nocpu_error() follow the same
>> rule. How about only invalidating it when it is populated?
>>
>> if (cpumask_empty(excpus) ||
>> (!cpumask_intersects(excpus, cpu_active_mask) &&
>> partition_is_populated(cs, NULL))) {
>
> A partition can only be created if there are active CPUs in the effective_xcpus.
> However, such a partition root can distribute its exclusive CPUs down to child
> local partitions with the results that effective_cpus can be empty if there is
> no task there. IOW, effective_xcpus must have active CPUs while effective_cpus
> does not need to have active CPUs if there are child partitions underneath. I am
> going to clarify that in the doc. I will check the hotplug path and
> task_nocpu_error() to make sure that it follows this rule. Does that rule make
> sense to you?
>
Yes, the rule makes sense to me, and it is clearer.
Note that the hotplug path currently keeps a partition with no task
valid after all its CPUs are offlined, e.g. these test cases in
test_cpuset_prs.sh:
" C2-3:P1 C3:P1 . . O3=0 . . . 0 A1:2|A2: A1:P1|A2:P1"
"$SETUP_A123_PARTITIONS . O3=0 . . . 0 A1:1|A2:2|A3:
A1:P1|A2:P1|A3:P1"
So the hotplug path and these test cases need to be updated together
with this patch to keep the behavior consistent?
>
>>
>> Also, it probably needs a Fixes tag, maybe:
>>
>> Fixes: f62a5d39368e ("cgroup/cpuset: Remove remote_partition_check() & make
>> update_cpumasks_hier() handle remote partition")
>
> Yes, I miss the fix tag. Will update that in the next version.
>
> Cheers,
> Longman
--
Best regards
Ridong
next prev parent reply other threads:[~2026-11-16 7:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 1:23 [PATCH-next v4 0/6] cgroup/cpuset: More fix patches Waiman Long
2026-11-16 1:23 ` [PATCH-next v4 1/6] cgroup/cpuset: Fix incorrect partition invalidation logic in cpuset_hotplug_update_tasks() Waiman Long
2026-11-16 10:19 ` Guopeng Zhang
2026-11-16 1:23 ` [PATCH-next v4 2/6] cgroup/cpuset: excpus parameter of remote_cpus_update() must have at least 1 active CPU Waiman Long
2026-11-16 3:07 ` Ridong Chen
2026-11-16 3:34 ` Waiman Long
2026-11-16 7:37 ` Ridong Chen [this message]
2026-11-16 1:23 ` [PATCH-next v4 3/6] cgroup/cpuset: Check remote partition underneath before making an invalid partition valid Waiman Long
2026-11-16 3:47 ` Ridong Chen
2026-11-16 4:21 ` Waiman Long
2026-11-16 1:23 ` [PATCH-next v4 4/6] cgroup/cpuset: Revert "remove global remote_children list" Waiman Long
2026-11-16 1:23 ` [PATCH-next v4 5/6] cgroup/cpuset: Handle remote partitions before local partitions in cpuset_handle_hotplug() Waiman Long
2026-11-16 7:08 ` Ridong Chen
2026-11-16 8:56 ` kernel test robot
2026-11-16 10:33 ` Guopeng Zhang
2026-11-16 1:23 ` [PATCH-next v4 6/6] cgroup/cpuset: Fix lockdep_is_cpuset_held() Waiman Long
2026-11-16 7:24 ` Ridong Chen
2026-11-17 4:06 ` Waiman Long
2026-11-16 10:34 ` Guopeng Zhang
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=8015ad75-0e4d-4928-8e56-8a495d752468@linux.dev \
--to=ridong.chen@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=sashiko-bot@kernel.org \
--cc=shuah@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.