aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/sched.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 5e220bf7d4c4..975436435b42 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2336,7 +2336,7 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2336 unsigned long max_pull; 2336 unsigned long max_pull;
2337 unsigned long busiest_load_per_task, busiest_nr_running; 2337 unsigned long busiest_load_per_task, busiest_nr_running;
2338 unsigned long this_load_per_task, this_nr_running; 2338 unsigned long this_load_per_task, this_nr_running;
2339 int load_idx; 2339 int load_idx, group_imb = 0;
2340#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 2340#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
2341 int power_savings_balance = 1; 2341 int power_savings_balance = 1;
2342 unsigned long leader_nr_running = 0, min_load_per_task = 0; 2342 unsigned long leader_nr_running = 0, min_load_per_task = 0;
@@ -2355,9 +2355,10 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2355 load_idx = sd->idle_idx; 2355 load_idx = sd->idle_idx;
2356 2356
2357 do { 2357 do {
2358 unsigned long load, group_capacity; 2358 unsigned long load, group_capacity, max_cpu_load, min_cpu_load;
2359 int local_group; 2359 int local_group;
2360 int i; 2360 int i;
2361 int __group_imb = 0;
2361 unsigned int balance_cpu = -1, first_idle_cpu = 0; 2362 unsigned int balance_cpu = -1, first_idle_cpu = 0;
2362 unsigned long sum_nr_running, sum_weighted_load; 2363 unsigned long sum_nr_running, sum_weighted_load;
2363 2364
@@ -2368,6 +2369,8 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2368 2369
2369 /* Tally up the load of all CPUs in the group */ 2370 /* Tally up the load of all CPUs in the group */
2370 sum_weighted_load = sum_nr_running = avg_load = 0; 2371 sum_weighted_load = sum_nr_running = avg_load = 0;
2372 max_cpu_load = 0;
2373 min_cpu_load = ~0UL;
2371 2374
2372 for_each_cpu_mask(i, group->cpumask) { 2375 for_each_cpu_mask(i, group->cpumask) {
2373 struct rq *rq; 2376 struct rq *rq;
@@ -2388,8 +2391,13 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2388 } 2391 }
2389 2392
2390 load = target_load(i, load_idx); 2393 load = target_load(i, load_idx);
2391 } else 2394 } else {
2392 load = source_load(i, load_idx); 2395 load = source_load(i, load_idx);
2396 if (load > max_cpu_load)
2397 max_cpu_load = load;
2398 if (min_cpu_load > load)
2399 min_cpu_load = load;
2400 }
2393 2401
2394 avg_load += load; 2402 avg_load += load;
2395 sum_nr_running += rq->nr_running; 2403 sum_nr_running += rq->nr_running;
@@ -2415,6 +2423,9 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2415 avg_load = sg_div_cpu_power(group, 2423 avg_load = sg_div_cpu_power(group,
2416 avg_load * SCHED_LOAD_SCALE); 2424 avg_load * SCHED_LOAD_SCALE);
2417 2425
2426 if ((max_cpu_load - min_cpu_load) > SCHED_LOAD_SCALE)
2427 __group_imb = 1;
2428
2418 group_capacity = group->__cpu_power / SCHED_LOAD_SCALE; 2429 group_capacity = group->__cpu_power / SCHED_LOAD_SCALE;
2419 2430
2420 if (local_group) { 2431 if (local_group) {
@@ -2423,11 +2434,12 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2423 this_nr_running = sum_nr_running; 2434 this_nr_running = sum_nr_running;
2424 this_load_per_task = sum_weighted_load; 2435 this_load_per_task = sum_weighted_load;
2425 } else if (avg_load > max_load && 2436 } else if (avg_load > max_load &&
2426 sum_nr_running > group_capacity) { 2437 (sum_nr_running > group_capacity || __group_imb)) {
2427 max_load = avg_load; 2438 max_load = avg_load;
2428 busiest = group; 2439 busiest = group;
2429 busiest_nr_running = sum_nr_running; 2440 busiest_nr_running = sum_nr_running;
2430 busiest_load_per_task = sum_weighted_load; 2441 busiest_load_per_task = sum_weighted_load;
2442 group_imb = __group_imb;
2431 } 2443 }
2432 2444
2433#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 2445#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -2499,6 +2511,9 @@ group_next:
2499 goto out_balanced; 2511 goto out_balanced;
2500 2512
2501 busiest_load_per_task /= busiest_nr_running; 2513 busiest_load_per_task /= busiest_nr_running;
2514 if (group_imb)
2515 busiest_load_per_task = min(busiest_load_per_task, avg_load);
2516
2502 /* 2517 /*
2503 * We're trying to get all the cpus to the average_load, so we don't 2518 * We're trying to get all the cpus to the average_load, so we don't
2504 * want to push ourselves above the average load, nor do we wish to 2519 * want to push ourselves above the average load, nor do we wish to