Skip to content

Commit

Permalink
sched: fix stale value in average load per task
Browse files Browse the repository at this point in the history
Impact: fix load balancer load average calculation accuracy

cpu_avg_load_per_task() returns a stale value when nr_running is 0.
It returns an older stale (caculated when nr_running was non zero) value.

This patch returns and sets rq->avg_load_per_task to zero when nr_running
is 0.

Compile and boot tested on a x86_64 box.

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Balbir Singh authored and Ingo Molnar committed Nov 12, 2008
1 parent f21f237 commit a2d4777
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,8 @@ static unsigned long cpu_avg_load_per_task(int cpu)

if (rq->nr_running)
rq->avg_load_per_task = rq->load.weight / rq->nr_running;
else
rq->avg_load_per_task = 0;

return rq->avg_load_per_task;
}
Expand Down

0 comments on commit a2d4777

Please sign in to comment.