Commit 595aac48 authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Ingo Molnar

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: default avatarArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarRik van Riel <riel@redhat.com>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: davej@redhat.com
LKML-Reference: <20100509082245.163e67ed@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b1f724c3
...@@ -150,14 +150,25 @@ static void tick_nohz_update_jiffies(ktime_t now) ...@@ -150,14 +150,25 @@ static void tick_nohz_update_jiffies(ktime_t now)
touch_softlockup_watchdog(); touch_softlockup_watchdog();
} }
static void tick_nohz_stop_idle(int cpu, ktime_t now) /*
* Updates the per cpu time idle statistics counters
*/
static void update_ts_time_stats(struct tick_sched *ts, ktime_t now)
{ {
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
ktime_t delta; ktime_t delta;
delta = ktime_sub(now, ts->idle_entrytime);
ts->idle_lastupdate = now; ts->idle_lastupdate = now;
if (ts->idle_active) {
delta = ktime_sub(now, ts->idle_entrytime);
ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
}
}
static void tick_nohz_stop_idle(int cpu, ktime_t now)
{
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
update_ts_time_stats(ts, now);
ts->idle_active = 0; ts->idle_active = 0;
sched_clock_idle_wakeup_event(0); sched_clock_idle_wakeup_event(0);
...@@ -165,14 +176,12 @@ static void tick_nohz_stop_idle(int cpu, ktime_t now) ...@@ -165,14 +176,12 @@ static void tick_nohz_stop_idle(int cpu, ktime_t now)
static ktime_t tick_nohz_start_idle(struct tick_sched *ts) static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
{ {
ktime_t now, delta; ktime_t now;
now = ktime_get(); now = ktime_get();
if (ts->idle_active) {
delta = ktime_sub(now, ts->idle_entrytime); update_ts_time_stats(ts, now);
ts->idle_lastupdate = now;
ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
}
ts->idle_entrytime = now; ts->idle_entrytime = now;
ts->idle_active = 1; ts->idle_active = 1;
sched_clock_idle_sleep_event(); sched_clock_idle_sleep_event();
......
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