[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251117024627.1128037-12-chenridong@huaweicloud.com>
Date: Mon, 17 Nov 2025 02:46:17 +0000
From: Chen Ridong <chenridong@...weicloud.com>
To: longman@...hat.com,
tj@...nel.org,
hannes@...xchg.org,
mkoutny@...e.com
Cc: cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org,
lujialin4@...wei.com,
chenridong@...wei.com
Subject: [PATCH -next 11/21] cpuset: user local_partition_disable() to invalidate local partition
From: Chen Ridong <chenridong@...wei.com>
Build on the local_partition_disable() infrastructure introduced in the
previous patch to handle local partition invalidation.
Additionally, correct the transition logic in cpuset_hotplug_update_tasks()
when determining whether to transition an invalid partition root, the check
should be based on non-empty user_xcpus rather than non-empty
effective_xcpus. This correction addresses the scenario where
exclusive_cpus is not set but cpus_allowed is configured. In this case,
effective_xcpus may be empty even though the partition should be considered
for re-enablement. The user_xcpus based check ensures proper partition
state transitions under these conditions.
Signed-off-by: Chen Ridong <chenridong@...wei.com>
---
kernel/cgroup/cpuset.c | 32 +++++++++-----------------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index fe166d7ed49d..770a28491cb7 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2028,22 +2028,6 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
adding = deleting = false;
old_prs = new_prs = cs->partition_root_state;
- if (cmd == partcmd_invalidate) {
- if (is_partition_invalid(cs))
- return 0;
-
- /*
- * Make the current partition invalid.
- */
- if (is_partition_valid(parent))
- adding = cpumask_and(tmp->addmask,
- xcpus, parent->effective_xcpus);
- if (old_prs > 0)
- new_prs = -old_prs;
-
- goto write_error;
- }
-
/*
* The parent must be a partition root.
* The new cpumask, if present, or the current cpus_allowed must
@@ -2619,7 +2603,7 @@ static int cpus_allowed_validate_change(struct cpuset *cs, struct cpuset *trialc
if (is_partition_valid(cp) &&
cpumask_intersects(xcpus, cp->effective_xcpus)) {
rcu_read_unlock();
- update_parent_effective_cpumask(cp, partcmd_invalidate, NULL, tmp);
+ local_partition_disable(cp, PERR_NOTEXCL, tmp);
rcu_read_lock();
}
}
@@ -2659,8 +2643,7 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,
trialcs->effective_xcpus, tmp);
} else {
if (trialcs->prs_err)
- update_parent_effective_cpumask(cs, partcmd_invalidate,
- NULL, tmp);
+ local_partition_disable(cs, trialcs->prs_err, tmp);
else
update_parent_effective_cpumask(cs, partcmd_update,
trialcs->effective_xcpus, tmp);
@@ -4104,18 +4087,21 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
* partitions.
*/
if (is_local_partition(cs) && (!is_partition_valid(parent) ||
- tasks_nocpu_error(parent, cs, &new_cpus)))
+ tasks_nocpu_error(parent, cs, &new_cpus))) {
partcmd = partcmd_invalidate;
+ local_partition_disable(cs, cs->prs_err, tmp);
+ }
/*
* On the other hand, an invalid partition root may be transitioned
- * back to a regular one with a non-empty effective xcpus.
+ * back to a regular one with a non-empty user xcpus.
*/
else if (is_partition_valid(parent) && is_partition_invalid(cs) &&
- !cpumask_empty(cs->effective_xcpus))
+ !cpumask_empty(user_xcpus(cs))) {
partcmd = partcmd_update;
+ update_parent_effective_cpumask(cs, partcmd, NULL, tmp);
+ }
if (partcmd >= 0) {
- update_parent_effective_cpumask(cs, partcmd, NULL, tmp);
if ((partcmd == partcmd_invalidate) || is_partition_valid(cs)) {
compute_partition_effective_cpumask(cs, &new_cpus);
cpuset_force_rebuild();
--
2.34.1
Powered by blists - more mailing lists