[PATCH v4 5/7] cgroup/cpuset: Fix isolation accounting on propagated invalidation
From: Guopeng Zhang
Date: Thu Sep 10 2026 - 05:54:46 EST
From: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
update_cpumasks_hier() invalidates a local partition when its parent
becomes a member or an invalid partition. Its CPUs return to the nearest
valid partition ancestor, but isolated_cpus still reflects the old
partition type.
This can be reproduced on a cgroup v2 system with CPUs 0-3 online:
cd /sys/fs/cgroup
echo +cpuset > cgroup.subtree_control
mkdir propagation-repro
echo 0-3 > propagation-repro/cpuset.cpus
echo root > propagation-repro/cpuset.cpus.partition
echo +cpuset > propagation-repro/cgroup.subtree_control
mkdir propagation-repro/child
echo 2-3 > propagation-repro/child/cpuset.cpus
echo isolated > propagation-repro/child/cpuset.cpus.partition
echo member > propagation-repro/cpuset.cpus.partition
cat cpuset.cpus.isolated
Without this fix, CPUs 2-3 remain isolated even though the child is
invalid and its CPUs have returned to the top partition. The expected
dynamic isolated mask is empty.
Update isolated_cpus before resetting a local partition whose state
changes from valid to invalid below an invalid parent. Remote partitions
are excluded because remote_partition_disable() already updates their
isolated CPU accounting.
Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Signed-off-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 7ba26b924086..bbc4868f026b 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2277,9 +2277,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
cpuset_for_each_descendant_pre(cp, pos_css, cs) {
struct cpuset *parent = parent_cs(cp);
bool remote = is_remote_partition(cp);
+ bool was_remote = remote;
bool update_parent = false;
+ int owner_prs;
old_prs = new_prs = cp->partition_root_state;
+ owner_prs = old_prs;
/*
* For child remote partition root (!= cs), we need to call
@@ -2379,7 +2382,18 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
new_prs = cp->partition_root_state;
}
+ /*
+ * With no valid parent partition left, this partition's CPUs
+ * return to the nearest valid partition ancestor.
+ */
+ if (!was_remote && old_prs > 0 && new_prs < 0 &&
+ !is_partition_valid(parent))
+ owner_prs = partition_owner(cp)->partition_root_state;
+
spin_lock_irq(&callback_lock);
+ if (old_prs != owner_prs)
+ isolated_cpus_update(old_prs, owner_prs,
+ cp->effective_xcpus);
cpumask_copy(cp->effective_cpus, tmp->new_cpus);
cp->partition_root_state = new_prs;
/*
--
2.43.0