public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] sched/update_avg: avoid negative time
@ 2014-01-21  5:33 Alex Shi
  2014-01-21  5:33 ` [PATCH 2/2] sched: add statistic for rq->max_idle_balance_cost Alex Shi
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Alex Shi @ 2014-01-21  5:33 UTC (permalink / raw)
  To: mingo, peterz, morten.rasmussen, vincent.guittot, daniel.lezcano,
	efault
  Cc: wangyun, linux-kernel, Alex Shi

rq->avg_idle try to reflect the average idle time between the cpu idle
and first wakeup. But in the function, it maybe get a negative value
if old avg_idle is too small. Then this negative value will be double
counted in next time calculation. Guess that is not the original purpose,
so recalibrate it to zero.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 30eb011..af9121c6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1358,6 +1358,9 @@ static void update_avg(u64 *avg, u64 sample)
 {
 	s64 diff = sample - *avg;
 	*avg += diff >> 3;
+
+	if (*avg < 0)
+		*avg = 0;
 }
 #endif
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-02-11 12:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21  5:33 [RFC PATCH 1/2] sched/update_avg: avoid negative time Alex Shi
2014-01-21  5:33 ` [PATCH 2/2] sched: add statistic for rq->max_idle_balance_cost Alex Shi
2014-01-21  7:43   ` Jason Low
2014-01-21  8:44     ` Alex Shi
2014-01-22  8:24     ` Alex Shi
2014-01-22 16:09       ` Peter Zijlstra
2014-01-22 18:10         ` Jason Low
2014-01-23  6:49           ` Alex Shi
2014-01-23  9:54             ` Peter Zijlstra
2014-01-23 10:49               ` Alex Shi
2014-01-23 12:32                 ` Morten Rasmussen
2014-01-23 14:43                   ` Alex Shi
2014-02-11 12:17                 ` [tip:sched/core] sched: Add statistic for newidle load balance cost tip-bot for Alex Shi
2014-01-21  5:59 ` [RFC PATCH 1/2] sched/update_avg: avoid negative time Alex Shi
2014-01-21  6:49 ` Michael wang
2014-01-21  8:46   ` Alex Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox