[PATCH v5 06/12] cpuset: use partition_update() for remote partition update
From: Ridong Chen
Date: Sat Nov 14 2026 - 03:32:44 EST
From: Ridong Chen <chenridong@xxxxxxxxxx>
Now that the partition_update() helper is available, use it to replace
the existing remote partition update logic. This unifies the update
path through a single centralized function.
Signed-off-by: Ridong Chen <chenridong@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 681adcde10e8..7a3e797aee52 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1835,8 +1835,8 @@ static void partition_disable(struct cpuset *cs, int new_prs,
* will be added to the subpartitions_cpus and removed from parent's
* effective_cpus, and the tmp->delmask vice versa.
*/
-static void __maybe_unused partition_update(struct cpuset *cs, int prs, struct cpumask *xcpus,
- struct cpumask *excpus, struct tmpmasks *tmp)
+static void partition_update(struct cpuset *cs, int prs, struct cpumask *xcpus,
+ struct cpumask *excpus, struct tmpmasks *tmp)
{
struct cpuset *parent;
@@ -1935,7 +1935,6 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
struct cpumask *excpus, struct tmpmasks *tmp)
{
- bool adding, deleting;
int prs = cs->partition_root_state;
if (WARN_ON_ONCE(!is_remote_partition(cs)))
@@ -1948,15 +1947,15 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
goto invalidate;
}
- adding = cpumask_andnot(tmp->addmask, excpus, cs->effective_xcpus);
- deleting = cpumask_andnot(tmp->delmask, cs->effective_xcpus, excpus);
+ cpumask_andnot(tmp->addmask, excpus, cs->effective_xcpus);
+ cpumask_andnot(tmp->delmask, cs->effective_xcpus, excpus);
/*
* Additions of remote CPUs is only allowed if those CPUs are
* not allocated to other partitions and there are effective_cpus
* left in the top cpuset.
*/
- if (adding) {
+ if (!cpumask_empty(tmp->addmask)) {
WARN_ON_ONCE(cpumask_intersects(tmp->addmask, subpartitions_cpus));
if (!capable(CAP_SYS_ADMIN))
WRITE_ONCE(cs->prs_err, PERR_ACCESS);
@@ -1971,22 +1970,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
}
cs->remote_partition_updating = true;
- spin_lock_irq(&callback_lock);
- if (adding)
- partition_xcpus_add(prs, NULL, tmp->addmask);
- if (deleting)
- partition_xcpus_del(prs, NULL, tmp->delmask);
- /*
- * Need to update effective_xcpus and exclusive_cpus now as
- * update_sibling_cpumasks() below may iterate back to the same cs.
- */
- cpumask_copy(cs->effective_xcpus, excpus);
- if (xcpus)
- cpumask_copy(cs->exclusive_cpus, xcpus);
- spin_unlock_irq(&callback_lock);
- if (adding || deleting)
- cpuset_force_rebuild();
-
+ partition_update(cs, prs, xcpus, excpus, tmp);
/*
* Propagate changes in top_cpuset's effective_cpus down the hierarchy.
*/
--
2.34.1