diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2014-07-24 00:03:50 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2014-07-24 06:02:49 -0400 |
commit | f723aa1817dd8f4fe005aab52ba70c8ab0ef9457 (patch) | |
tree | de785d92689f9a585c3cfd2a019d6e838c770426 | |
parent | 82e13c71bc655b6dc7110da4e164079dadb44892 (diff) |
sched_clock: Avoid corrupting hrtimer tree during suspend
During suspend we call sched_clock_poll() to update the epoch and
accumulated time and reprogram the sched_clock_timer to fire
before the next wrap-around time. Unfortunately,
sched_clock_poll() doesn't restart the timer, instead it relies
on the hrtimer layer to do that and during suspend we aren't
calling that function from the hrtimer layer. Instead, we're
reprogramming the expires time while the hrtimer is enqueued,
which can cause the hrtimer tree to be corrupted. Furthermore, we
restart the timer during suspend but we update the epoch during
resume which seems counter-intuitive.
Let's fix this by saving the accumulated state and canceling the
timer during suspend. On resume we can update the epoch and
restart the timer similar to what we would do if we were starting
the clock for the first time.
Fixes: a08ca5d1089d "sched_clock: Use an hrtimer instead of timer"
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Link: http://lkml.kernel.org/r/1406174630-23458-1-git-send-email-john.stultz@linaro.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | kernel/time/sched_clock.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 445106d2c729..01d2d15aa662 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c | |||
@@ -191,7 +191,8 @@ void __init sched_clock_postinit(void) | |||
191 | 191 | ||
192 | static int sched_clock_suspend(void) | 192 | static int sched_clock_suspend(void) |
193 | { | 193 | { |
194 | sched_clock_poll(&sched_clock_timer); | 194 | update_sched_clock(); |
195 | hrtimer_cancel(&sched_clock_timer); | ||
195 | cd.suspended = true; | 196 | cd.suspended = true; |
196 | return 0; | 197 | return 0; |
197 | } | 198 | } |
@@ -199,6 +200,7 @@ static int sched_clock_suspend(void) | |||
199 | static void sched_clock_resume(void) | 200 | static void sched_clock_resume(void) |
200 | { | 201 | { |
201 | cd.epoch_cyc = read_sched_clock(); | 202 | cd.epoch_cyc = read_sched_clock(); |
203 | hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); | ||
202 | cd.suspended = false; | 204 | cd.suspended = false; |
203 | } | 205 | } |
204 | 206 | ||