[PATCH v2 3/3] cgroup/cpuset: Release isolated CPUs when the parent is invalid
From: Guopeng Zhang
Date: Thu Nov 05 2026 - 08:08:59 EST
From: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
An isolated partition can be invalidated after its parent has already
become invalid. update_parent_effective_cpumask() then skips returning
CPUs to the parent, but also skips removing them from isolated_cpus.
The invalid child continues to isolate CPUs that no longer belong to
any valid isolated partition.
For example, on a 32-CPU system with all CPUs online and without
isolcpus= or nohz_full= boot parameters:
cd /sys/fs/cgroup
echo +cpuset > cgroup.subtree_control
mkdir A
echo 0,2-31 > A/cpuset.cpus
echo root > A/cpuset.cpus.partition
echo +cpuset > A/cgroup.subtree_control
mkdir A/B
echo 2-3 > A/B/cpuset.cpus
echo isolated > A/B/cpuset.cpus.partition
cat cpuset.cpus.isolated
2-3
echo 0 > /sys/devices/system/cpu/cpu1/online
cat A/B/cpuset.cpus.partition
isolated invalid
cat cpuset.cpus.isolated
2-3
Release the invalidated child's isolated CPUs when its parent is no
longer a valid partition. Use isolated_cpus_release() to preserve CPUs
still covered by a valid isolated ancestor and by boot isolation.
After this fix, cpuset.cpus.isolated is empty for this reproducer.
Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Signed-off-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index fc5454c2740f..f3b808cea51c 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1976,10 +1976,15 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
/*
* Make the current partition invalid.
*/
- if (is_partition_valid(parent))
+ if (is_partition_valid(parent)) {
adding = cpumask_and(tmp->addmask,
cs->effective_xcpus,
parent->effective_xcpus);
+ } else if (old_prs == PRS_ISOLATED) {
+ /* No valid parent will release these isolated CPUs. */
+ cpumask_copy(tmp->addmask, cs->effective_xcpus);
+ isolated_cpus_release(cs, tmp->addmask);
+ }
if (old_prs > 0)
new_prs = -old_prs;
--
2.43.0