mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/topology: Retry scheduler domains after failed construction
@ 2026-10-31 12:49 Avi Weiss
  0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-10-31 12:49 UTC (permalink / raw)
  To: mingo, peterz
  Cc: juri.lelli, vincent.guittot, dietmar.eggemann, vschneid,
	kprateek.nayak, mgorman, linux-kernel

partition_sched_domains_locked() records requested partitions even when
build_sched_domains() fails. An identical rebuild then reuses the failed
partition, leaving its CPUs attached to the default root domain after a
transient allocation failure.

Check that the root domain is installed before reusing or detaching a
partition. This allows the next rebuild to retry failed construction
without rebuilding successfully installed partitions.

Reproduced with an alloc_rootdomain() failure in a four-vCPU QEMU guest.
The unpatched kernel skipped an identical rebuild, while the patched
kernel restored the scheduling domains.

Fixes: 029190c515f1 ("cpuset sched_load_balance flag")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/sched/topology.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 919d0fb00bd9..b3c4bc13875c 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -3346,6 +3346,13 @@ static void detach_destroy_domains(const struct cpumask *cpu_map)
 	rcu_read_unlock();
 }
 
+/* A failed domain build leaves its CPUs attached to def_root_domain. */
+static bool sched_domain_installed(const struct cpumask *cpu_map)
+{
+	return !cpumask_empty(cpu_map) &&
+	       cpu_rq(cpumask_first(cpu_map))->rd != &def_root_domain;
+}
+
 /* handle null as "default" */
 static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur,
 			struct sched_domain_attr *new, int idx_new)
@@ -3422,11 +3429,13 @@ static void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new
 	for (i = 0; i < ndoms_cur; i++) {
 		for (j = 0; j < n && !new_topology; j++) {
 			if (cpumask_equal(doms_cur[i], doms_new[j]) &&
-			    dattrs_equal(dattr_cur, i, dattr_new, j))
+			    dattrs_equal(dattr_cur, i, dattr_new, j) &&
+			    sched_domain_installed(doms_cur[i]))
 				goto match1;
 		}
 		/* No match - a current sched domain not in new doms_new[] */
-		detach_destroy_domains(doms_cur[i]);
+		if (sched_domain_installed(doms_cur[i]))
+			detach_destroy_domains(doms_cur[i]);
 match1:
 		;
 	}
@@ -3443,7 +3452,8 @@ static void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new
 	for (i = 0; i < ndoms_new; i++) {
 		for (j = 0; j < n && !new_topology; j++) {
 			if (cpumask_equal(doms_new[i], doms_cur[j]) &&
-			    dattrs_equal(dattr_new, i, dattr_cur, j)) {
+			    dattrs_equal(dattr_new, i, dattr_cur, j) &&
+			    sched_domain_installed(doms_cur[j])) {
 				/*
 				 * Reused partition has to be taken care
 				 * of here, because there could be a corner

base-commit: 36aad21d50d1af3f6954bb0c988257a908202477
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-31 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 12:49 [PATCH] sched/topology: Retry scheduler domains after failed construction Avi Weiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®