mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, vschneid@redhat.com,
	kprateek.nayak@amd.com, mgorman@suse.de,
	linux-kernel@vger.kernel.org
Subject: [PATCH] sched/topology: Retry scheduler domains after failed construction
Date: Sat, 31 Oct 2026 14:49:50 +0200	[thread overview]
Message-ID: <20261031124949.3904462-2-thnkslprpt@gmail.com> (raw)

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


                 reply	other threads:[~2026-10-31 12:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261031124949.3904462-2-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®