Skip to content

Commit

Permalink
sched/fair: Remove duplicate load_per_task computations
Browse files Browse the repository at this point in the history
Since we already compute (but don't store) the sgs load_per_task value
in update_sg_lb_stats() we might as well store it and not re-compute
it later on.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-ym1vmljiwbzgdnnrwp9azftq@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 2, 2013
1 parent 147c5fc commit 38d0f77
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -4476,7 +4476,6 @@ static inline void update_sg_lb_stats(struct lb_env *env,
{
unsigned long nr_running, max_nr_running, min_nr_running;
unsigned long load, max_cpu_load, min_cpu_load;
unsigned long avg_load_per_task = 0;
int i;

/* Tally up the load of all CPUs in the group */
Expand Down Expand Up @@ -4531,9 +4530,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
* the hierarchy?
*/
if (sgs->sum_nr_running)
avg_load_per_task = sgs->sum_weighted_load / sgs->sum_nr_running;
sgs->load_per_task = sgs->sum_weighted_load / sgs->sum_nr_running;

if ((max_cpu_load - min_cpu_load) >= avg_load_per_task &&
if ((max_cpu_load - min_cpu_load) >= sgs->load_per_task &&
(max_nr_running - min_nr_running) > 1)
sgs->group_imb = 1;

Expand Down Expand Up @@ -4776,15 +4775,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
struct sg_lb_stats *local, *busiest;

local = &sds->local_stat;
if (local->sum_nr_running) {
local->load_per_task =
local->sum_weighted_load / local->sum_nr_running;
}

busiest = &sds->busiest_stat;
/* busiest must have some tasks */
busiest->load_per_task =
busiest->sum_weighted_load / busiest->sum_nr_running;

if (busiest->group_imb) {
busiest->load_per_task =
Expand Down

0 comments on commit 38d0f77

Please sign in to comment.