From: Michael Bohan <mbohan@codeaurora.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: [PATCH 2/2] hrtimer: Prevent enqueue of hrtimer on dead CPU
Date: Wed, 10 Apr 2013 14:07:48 -0700 [thread overview]
Message-ID: <1365628068-32738-3-git-send-email-mbohan@codeaurora.org> (raw)
In-Reply-To: <1365628068-32738-1-git-send-email-mbohan@codeaurora.org>
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.
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
---
kernel/hrtimer.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 3f0bce9..54c5d98 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -227,7 +227,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();
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2013-04-10 21:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 21:07 [PATCH 0/2] hrtimer preemption bug fixes Michael Bohan
2013-04-10 21:07 ` [PATCH 1/2] hrtimer: Consider preemption when migrating hrtimer cpu_bases Michael Bohan
2013-04-18 9:40 ` Thomas Gleixner
2013-04-19 1:37 ` Michael Bohan
2013-04-10 21:07 ` Michael Bohan [this message]
2013-04-18 9:44 ` [PATCH 2/2] hrtimer: Prevent enqueue of hrtimer on dead CPU Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365628068-32738-3-git-send-email-mbohan@codeaurora.org \
--to=mbohan@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox