From 512c41113e644d23240b99a07a96ccc7065dd1fb Mon Sep 17 00:00:00 2001 From: Jason Low Date: Sat, 31 Aug 2013 01:47:10 -0500 Subject: sched: Reduce overestimating rq->avg_idle Date Thu, 29 Aug 2013 13:05:34 -0700 When updating avg_idle, if the delta exceeds some max value, then avg_idle gets set to the max, regardless of what the previous avg was. This can cause avg_idle to often be overestimated. This patch modifies the way we update avg_idle by always updating it with the function call to update_avg() first. Then, if avg_idle exceeds the max, we set it to the max. Signed-off-by: Jason Low Reviewed-by: Rik van Riel Signed-off-by: Paul Reioux Signed-off-by: engstk --- kernel/sched/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'kernel') diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ed57354ad..22b248d7d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1505,10 +1505,11 @@ ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags) u64 delta = rq->clock - rq->idle_stamp; u64 max = 2*sysctl_sched_migration_cost; - if (delta > max) + update_avg(&rq->avg_idle, delta); + + if (rq->avg_idle > max) rq->avg_idle = max; - else - update_avg(&rq->avg_idle, delta); + rq->idle_stamp = 0; } #endif -- cgit v1.2.3