LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: tip-bot for Dexuan Cui <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, fweisbec@gmail.com, kys@microsoft.com,
dvyukov@google.com, adobriyan@gmail.com,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
mingo@kernel.org, akpm@linux-foundation.org,
torvalds@linux-foundation.org, rakib.mullick@gmail.com,
decui@microsoft.com, Michael.H.Kelley@microsoft.com,
hpa@zytor.com, jopoulso@microsoft.com, peterz@infradead.org,
Jork.Loeser@microsoft.com
Subject: [tip:timers/urgent] tick/broadcast: Use for_each_cpu() specially on UP kernels
Date: Tue, 15 May 2018 13:48:55 -0700 [thread overview]
Message-ID: <tip-5596fe34495cf0f645f417eb928ef224df3e3cb4@git.kernel.org> (raw)
In-Reply-To: <KL1P15301MB0006FA63BC22BEB64902EAA0BF930@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM>
Commit-ID: 5596fe34495cf0f645f417eb928ef224df3e3cb4
Gitweb: https://git.kernel.org/tip/5596fe34495cf0f645f417eb928ef224df3e3cb4
Author: Dexuan Cui <decui@microsoft.com>
AuthorDate: Tue, 15 May 2018 19:52:50 +0000
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 15 May 2018 22:45:54 +0200
tick/broadcast: Use for_each_cpu() specially on UP kernels
for_each_cpu() unintuitively reports CPU0 as set independent of the actual
cpumask content on UP kernels. This causes an unexpected PIT interrupt
storm on a UP kernel running in an SMP virtual machine on Hyper-V, and as
a result, the virtual machine can suffer from a strange random delay of 1~20
minutes during boot-up, and sometimes it can hang forever.
Protect if by checking whether the cpumask is empty before entering the
for_each_cpu() loop.
[ tglx: Use !IS_ENABLED(CONFIG_SMP) instead of #ifdeffery ]
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poulson <jopoulso@microsoft.com>
Cc: "Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: stable@vger.kernel.org
Cc: Rakib Mullick <rakib.mullick@gmail.com>
Cc: Jork Loeser <Jork.Loeser@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: KY Srinivasan <kys@microsoft.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Link: https://lkml.kernel.org/r/KL1P15301MB000678289FE55BA365B3279ABF990@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM
Link: https://lkml.kernel.org/r/KL1P15301MB0006FA63BC22BEB64902EAA0BF930@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM
---
kernel/time/tick-broadcast.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index b398c2ea69b2..aa2094d5dd27 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -612,6 +612,14 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
now = ktime_get();
/* Find all expired events */
for_each_cpu(cpu, tick_broadcast_oneshot_mask) {
+ /*
+ * Required for !SMP because for_each_cpu() reports
+ * unconditionally CPU0 as set on UP kernels.
+ */
+ if (!IS_ENABLED(CONFIG_SMP) &&
+ cpumask_empty(tick_broadcast_oneshot_mask))
+ break;
+
td = &per_cpu(tick_cpu_device, cpu);
if (td->evtdev->next_event <= now) {
cpumask_set_cpu(cpu, tmpmask);
prev parent reply other threads:[~2018-05-15 20:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 6:24 for_each_cpu() is buggy for UP kernel? Dexuan Cui
2018-05-09 23:20 ` Andrew Morton
2018-05-13 13:35 ` Thomas Gleixner
2018-05-13 18:21 ` Linus Torvalds
2018-05-14 7:28 ` Dmitry Vyukov
2018-05-15 3:02 ` Dexuan Cui
2018-05-15 17:21 ` Linus Torvalds
2018-05-15 20:10 ` Dexuan Cui
2018-05-15 19:52 ` [PATCH] tick/broadcast: Use for_each_cpu() specially on UP kernels Dexuan Cui
2018-05-15 20:48 ` tip-bot for Dexuan Cui [this message]
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=tip-5596fe34495cf0f645f417eb928ef224df3e3cb4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=Jork.Loeser@microsoft.com \
--cc=Michael.H.Kelley@microsoft.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=decui@microsoft.com \
--cc=dvyukov@google.com \
--cc=fweisbec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jopoulso@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rakib.mullick@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--subject='Re: [tip:timers/urgent] tick/broadcast: Use for_each_cpu() specially on UP kernels' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).