sched/topology: Retry scheduler domains after failed construction
PATCH 1/1 sched/topology: Retry scheduler domains after failed construction
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 <[email protected]>
--- kernel/sched/topology.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/sched/topology.c +13 -3
@@ -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_newfor (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_newfor (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
Signature · 1 line
2.43.0