diff options
author | Peter Zijlstra <peterz@infradead.org> | 2017-04-21 13:43:59 +0300 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-05-15 11:15:20 +0300 |
commit | f9fccdb9efef60dbcf84d493514b475c41aa866f (patch) | |
tree | 3d5278febf2aa2f0d8d2e05977c59bcd97fce350 /kernel/sched/clock.c | |
parent | 3067a33d5fec856bb297d58e7f03411d060ccdee (diff) | |
download | linux-f9fccdb9efef60dbcf84d493514b475c41aa866f.tar.xz |
cpuidle: Fix idle time tracking
Ville reported that on his Core2, which has TSC stop in idle, we would
always report very short idle durations. He tracked this down to
commit:
e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
which replaces ktime_get() with local_clock().
Add a sched_clock_idle_wakeup_event() call, which will re-sync the
clock with ktime_get_ns() when TSC is unstable and no-op otherwise.
Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Fixes: e93e59ce5b85 ("cpuidle: Replace ktime_get() with local_clock()")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/clock.c')
-rw-r--r-- | kernel/sched/clock.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index c30c05f05d6f..d4c2f89fac92 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -410,14 +410,21 @@ void sched_clock_idle_sleep_event(void) EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event); /* - * We just idled; resync with ktime. (called with irqs disabled): + * We just idled; resync with ktime. */ void sched_clock_idle_wakeup_event(void) { - if (timekeeping_suspended) + unsigned long flags; + + if (sched_clock_stable()) + return; + + if (unlikely(timekeeping_suspended)) return; + local_irq_save(flags); sched_clock_tick(); + local_irq_restore(flags); } EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); |