diff options
| author | Michael Bohan <mbohan@codeaurora.org> | 2013-04-12 13:42:11 -0500 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-09-11 11:31:31 +0200 |
| commit | 50c4bae31c7ca303166ee21ac19bf6d1617143cb (patch) | |
| tree | 61e2de41feac395001c51b571279c739896d5f61 | |
| parent | 644ea5676b133a06c34332fff4a22dc7280c7bb4 (diff) | |
hrtimer: Prevent enqueue of hrtimer on dead CPU
Date Wed, 10 Apr 2013 14:07:48 -0700
When switching the hrtimer cpu_base, we briefly allow for
preemption to become enabled by unlocking the cpu_base lock.
During this time, the CPU corresponding to the new cpu_base
that was selected may in fact go offline. In this scenario, the
hrtimer is enqueued to a CPU that's not online, and therefore
it never fires.
As an example, consider this example:
CPU #0 CPU #1
---- ----
... hrtimer_start()
lock_hrtimer_base()
switch_hrtimer_base()
cpu = hrtimer_get_target() -> 1
spin_unlock(&cpu_base->lock)
<migrate thread to CPU #0>
<offline>
spin_lock(&new_base->lock)
this_cpu = 0
cpu != this_cpu
enqueue_hrtimer(cpu_base #1)
To prevent this scenario, verify that the CPU corresponding to
the new cpu_base is indeed online before selecting it in
hrtimer_switch_base(). If it's not online, fallback to using the
base of the current CPU.
Change-Id: I3aaf5b806a25d5a8b96d6ccea7a042d2718091f7
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
| -rw-r--r-- | kernel/hrtimer.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 7832f70f4..9268fee2f 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -243,7 +243,8 @@ again: this_cpu = smp_processor_id(); - if (cpu != this_cpu && hrtimer_check_target(timer, new_base)) { + if (cpu != this_cpu && (hrtimer_check_target(timer, new_base) + || !cpu_online(cpu))) { raw_spin_unlock(&new_base->cpu_base->lock); raw_spin_lock(&base->cpu_base->lock); cpu = smp_processor_id(); |
