[RFC PATCH -v4 17/22] cpuset: use partition_disable for compute_partition_effective_cpumask

From: Ridong Chen

Date: Sun Nov 01 2026 - 06:46:16 EST


From: Chen Ridong <chenridong@xxxxxxxxxx>

Replace the partition invalidation logic in the
compute_partition_effective_cpumask() with a call to partition_disable().

This centralizes partition state management and ensures consistent
handling of partition disable operations throughout the cpuset subsystem.
The isolated_cpus update that was open-coded here is now done by
partition_xcpus_del() called from partition_disable(). In addition,
partition_disable() gives the exclusive CPUs of the invalidated child
back to the parent and resets the partition data of the child, the
same as other partition invalidation paths.

Signed-off-by: Chen Ridong <chenridong@xxxxxxxxxx>
Signed-off-by: Ridong Chen <chenridong@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 00afa4987381..af42666d4530 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1137,6 +1137,8 @@ void cpuset_update_tasks_cpumask(struct cpuset *cs, struct cpumask *new_cpus)

static void update_sibling_cpumasks(struct cpuset *parent, struct cpuset *cs,
struct tmpmasks *tmp);
+static void partition_disable(struct cpuset *cs, struct cpuset *parent,
+ int new_prs, enum prs_errcode prs_err);

/*
* Update partition load balance flag and/or rebuild sched domain
@@ -1642,20 +1644,9 @@ static void compute_partition_effective_cpumask(struct cpuset *cs,
*/
WARN_ON_ONCE(is_remote_partition(child));
if (populated && cpumask_subset(new_ecpus, child->effective_xcpus)) {
- int old_prs = child->partition_root_state;
- int parent_prs = cs->partition_root_state;
-
- /*
- * Invalidate child partition. Its CPUs, including those
- * further distributed to its descendants, take the
- * isolation state of cs.
- */
- spin_lock_irq(&callback_lock);
- WRITE_ONCE(child->prs_err, PERR_NOCPUS);
- isolated_cpus_set_state(parent_prs, child->effective_xcpus);
- child->partition_root_state = -old_prs;
- spin_unlock_irq(&callback_lock);
- notify_partition_change(child, old_prs);
+ /* Invalidate child partition */
+ partition_disable(child, cs, -child->partition_root_state,
+ PERR_NOCPUS);
continue;
}
cpumask_andnot(new_ecpus, new_ecpus,
--
2.34.1