Re: [PATCH-next v4 2/6] cgroup/cpuset: excpus parameter of remote_cpus_update() must have at least 1 active CPU
From: Waiman Long
Date: Sun Nov 15 2026 - 22:34:58 EST
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@xxxxxxxxxx>
Link: https://sashiko.dev/#/bug/linux-936b7155-f652-4146-a4ab-ec48fd392a1d
Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
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?
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