[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251118083643.1363020-1-chenridong@huaweicloud.com>
Date: Tue, 18 Nov 2025 08:36:43 +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,
daniel.m.jordan@...cle.com,
lujialin4@...wei.com,
chenridong@...wei.com
Subject: [PATCH -next] cpuset: Remove unnecessary checks in rebuild_sched_domains_locked
From: Chen Ridong <chenridong@...wei.com>
Commit 406100f3da08 ("cpuset: fix race between hotplug work and later CPU
offline")added a check for empty effective_cpus in partitions for cgroup
v2. However, thischeck did not account for remote partitions, which were
introduced later.
After commit 2125c0034c5d ("cgroup/cpuset: Make cpuset hotplug processing
synchronous"),cgroup v2's cpuset hotplug handling is now synchronous. This
eliminates the race condition with subsequent CPU offline operations that
the original check aimed to fix.
Instead of extending the check to support remote partitions, this patch
removes the redundant partition effective_cpus check. Additionally, it adds
a check and warningto verify that all generated sched domains consist of
active CPUs, preventing partition_sched_domains from being invoked with
offline CPUs.
Signed-off-by: Chen Ridong <chenridong@...wei.com>
---
kernel/cgroup/cpuset.c | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index daf813386260..1ac58e3f26b4 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1084,11 +1084,10 @@ void dl_rebuild_rd_accounting(void)
*/
void rebuild_sched_domains_locked(void)
{
- struct cgroup_subsys_state *pos_css;
struct sched_domain_attr *attr;
cpumask_var_t *doms;
- struct cpuset *cs;
int ndoms;
+ int i;
lockdep_assert_cpus_held();
lockdep_assert_held(&cpuset_mutex);
@@ -1107,30 +1106,14 @@ void rebuild_sched_domains_locked(void)
!cpumask_equal(top_cpuset.effective_cpus, cpu_active_mask))
return;
- /*
- * With subpartition CPUs, however, the effective CPUs of a partition
- * root should be only a subset of the active CPUs. Since a CPU in any
- * partition root could be offlined, all must be checked.
- */
- if (!cpumask_empty(subpartitions_cpus)) {
- rcu_read_lock();
- cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
- if (!is_partition_valid(cs)) {
- pos_css = css_rightmost_descendant(pos_css);
- continue;
- }
- if (!cpumask_subset(cs->effective_cpus,
- cpu_active_mask)) {
- rcu_read_unlock();
- return;
- }
- }
- rcu_read_unlock();
- }
-
/* Generate domain masks and attrs */
ndoms = generate_sched_domains(&doms, &attr);
+ for (i = 0; i < ndoms; ++i) {
+ if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask)))
+ return;
+ }
+
/* Have scheduler rebuild the domains */
partition_sched_domains(ndoms, doms, attr);
}
--
2.34.1
Powered by blists - more mailing lists