aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-05-09 11:22:45 -0400
committerIngo Molnar <mingo@elte.hu>2010-05-09 13:35:25 -0400
commit595aac488b546c7185be7e29c8ae165a588b2a9f (patch)
tree5037879b01cbcb7cf84f4ab99a114aca687f0300 /kernel/time
parentb1f724c3055fa75a31d272222213647547a2d3d4 (diff)
sched: Introduce a function to update the idle statistics
Currently, two places update the idle statistics (and more to come later in this series). This patch creates a helper function for updating these statistics. 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: <20100509082245.163e67ed@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/tick-sched.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 358822ee32d5..59d8762c7e1d 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -150,14 +150,25 @@ static void tick_nohz_update_jiffies(ktime_t now)
150 touch_softlockup_watchdog(); 150 touch_softlockup_watchdog();
151} 151}
152 152
153static void tick_nohz_stop_idle(int cpu, ktime_t now) 153/*
154 * Updates the per cpu time idle statistics counters
155 */
156static void update_ts_time_stats(struct tick_sched *ts, ktime_t now)
154{ 157{
155 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
156 ktime_t delta; 158 ktime_t delta;
157 159
158 delta = ktime_sub(now, ts->idle_entrytime);
159 ts->idle_lastupdate = now; 160 ts->idle_lastupdate = now;
160 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); 161 if (ts->idle_active) {
162 delta = ktime_sub(now, ts->idle_entrytime);
163 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
164 }
165}
166
167static void tick_nohz_stop_idle(int cpu, ktime_t now)
168{
169 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
170
171 update_ts_time_stats(ts, now);
161 ts->idle_active = 0; 172 ts->idle_active = 0;
162 173
163 sched_clock_idle_wakeup_event(0); 174 sched_clock_idle_wakeup_event(0);
@@ -165,14 +176,12 @@ static void tick_nohz_stop_idle(int cpu, ktime_t now)
165 176
166static ktime_t tick_nohz_start_idle(struct tick_sched *ts) 177static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
167{ 178{
168 ktime_t now, delta; 179 ktime_t now;
169 180
170 now = ktime_get(); 181 now = ktime_get();
171 if (ts->idle_active) { 182
172 delta = ktime_sub(now, ts->idle_entrytime); 183 update_ts_time_stats(ts, now);
173 ts->idle_lastupdate = now; 184
174 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
175 }
176 ts->idle_entrytime = now; 185 ts->idle_entrytime = now;
177 ts->idle_active = 1; 186 ts->idle_active = 1;
178 sched_clock_idle_sleep_event(); 187 sched_clock_idle_sleep_event();