aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-05-09 11:23:23 -0400
committerIngo Molnar <mingo@elte.hu>2010-05-09 13:35:26 -0400
commit8c7b09f43f4bf570654bcc458ce96819a932303c (patch)
tree33eb6f860fa9a31ea63b67247890a6762439fde2 /kernel/time/tick-sched.c
parent595aac488b546c7185be7e29c8ae165a588b2a9f (diff)
sched: Update the idle statistics in get_cpu_idle_time_us()
Right now, get_cpu_idle_time_us() only reports the idle statistics upto the point the CPU entered last idle; not what is valid right now. This patch adds an update of the idle statistics to get_cpu_idle_time_us(), so that calling this function always returns statistics that are accurate at the point of the call. This includes resetting the start of the idle time for accounting purposes to avoid double accounting. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Rik van Riel <riel@redhat.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: davej@redhat.com LKML-Reference: <20100509082323.2d2f1945@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 59d8762c7e1d..f15d18d82c18 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -161,6 +161,7 @@ static void update_ts_time_stats(struct tick_sched *ts, ktime_t now)
161 if (ts->idle_active) { 161 if (ts->idle_active) {
162 delta = ktime_sub(now, ts->idle_entrytime); 162 delta = ktime_sub(now, ts->idle_entrytime);
163 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); 163 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
164 ts->idle_entrytime = now;
164 } 165 }
165} 166}
166 167
@@ -205,14 +206,18 @@ static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
205u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time) 206u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
206{ 207{
207 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); 208 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
209 ktime_t now;
208 210
209 if (!tick_nohz_enabled) 211 if (!tick_nohz_enabled)
210 return -1; 212 return -1;
211 213
214 now = ktime_get();
215 update_ts_time_stats(ts, now);
216
212 if (ts->idle_active) 217 if (ts->idle_active)
213 *last_update_time = ktime_to_us(ts->idle_lastupdate); 218 *last_update_time = ktime_to_us(ts->idle_lastupdate);
214 else 219 else
215 *last_update_time = ktime_to_us(ktime_get()); 220 *last_update_time = ktime_to_us(now);
216 221
217 return ktime_to_us(ts->idle_sleeptime); 222 return ktime_to_us(ts->idle_sleeptime);
218} 223}