]> git.karo-electronics.de Git - linux-beck.git/commitdiff
sched/fair: Let minimally loaded cpu balance the group
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Fri, 20 Apr 2012 14:57:22 +0000 (16:57 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 9 May 2012 13:00:51 +0000 (15:00 +0200)
Currently we let the leftmost (or first idle) cpu ascend the
sched_domain tree and perform load-balancing. The result is that the
busiest cpu in the group might be performing this function and pull
more load to itself. The next load balance pass will then try to
equalize this again.

Change this to pick the least loaded cpu to perform higher domain
balancing.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-v8zlrmgmkne3bkcy9dej1fvm@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/fair.c

index 678966ca393b822eaa12fdd3b7803e3b38927a53..968ffee24721f9c69ddbba8ddda52b6db1784325 100644 (file)
@@ -3781,7 +3781,8 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
 {
        unsigned long load, max_cpu_load, min_cpu_load, max_nr_running;
        int i;
-       unsigned int balance_cpu = -1, first_idle_cpu = 0;
+       unsigned int balance_cpu = -1;
+       unsigned long balance_load = ~0UL;
        unsigned long avg_load_per_task = 0;
 
        if (local_group)
@@ -3797,12 +3798,11 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
 
                /* Bias balancing toward cpus of our domain */
                if (local_group) {
-                       if (idle_cpu(i) && !first_idle_cpu) {
-                               first_idle_cpu = 1;
+                       load = target_load(i, load_idx);
+                       if (load < balance_load || idle_cpu(i)) {
+                               balance_load = load;
                                balance_cpu = i;
                        }
-
-                       load = target_load(i, load_idx);
                } else {
                        load = source_load(i, load_idx);
                        if (load > max_cpu_load) {