Commit a2d47777 authored by Balbir Singh's avatar Balbir Singh Committed by Ingo Molnar

sched: fix stale value in average load per task

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: default avatarBalbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f21f237c
...@@ -1456,6 +1456,8 @@ static unsigned long cpu_avg_load_per_task(int cpu) ...@@ -1456,6 +1456,8 @@ static unsigned long cpu_avg_load_per_task(int cpu)
if (rq->nr_running) if (rq->nr_running)
rq->avg_load_per_task = rq->load.weight / 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; return rq->avg_load_per_task;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment