]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
sched/topology: Avoid pointless rebuild
authorPeter Zijlstra <peterz@infradead.org>
Tue, 8 Aug 2017 10:16:24 +0000 (12:16 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 25 Aug 2017 09:12:20 +0000 (11:12 +0200)
Fix partition_sched_domains() to try and preserve the existing machine
wide domain instead of unconditionally destroying it. We do this by
attempting to allocate the new single domain, only when that fails to
we reuse the fallback_doms.

When using fallback_doms we need to first destroy and then recreate
because both the old and new could be backed by it.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ofer Levi(SW) <oferle@mellanox.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vineet.Gupta1@synopsys.com <Vineet.Gupta1@synopsys.com>
Cc: rusty@rustcorp.com.au <rusty@rustcorp.com.au>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/topology.c

index 179b90b60ec6a9d250c68a76c16c46c19e69a621..727daa2a0abe962d3bbd9bcde62a099360d75d41 100644 (file)
@@ -1851,7 +1851,17 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
        /* Let the architecture update CPU core mappings: */
        new_topology = arch_update_cpu_topology();
 
-       n = doms_new ? ndoms_new : 0;
+       if (!doms_new) {
+               WARN_ON_ONCE(dattr_new);
+               n = 0;
+               doms_new = alloc_sched_domains(1);
+               if (doms_new) {
+                       n = 1;
+                       cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_map);
+               }
+       } else {
+               n = ndoms_new;
+       }
 
        /* Destroy deleted domains: */
        for (i = 0; i < ndoms_cur; i++) {
@@ -1867,11 +1877,10 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
        }
 
        n = ndoms_cur;
-       if (doms_new == NULL) {
+       if (!doms_new) {
                n = 0;
                doms_new = &fallback_doms;
                cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_map);
-               WARN_ON_ONCE(dattr_new);
        }
 
        /* Build new domains: */