From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Pavel Machek <pavel@ucw.cz>, "Rafael J. Wysocki" <rjw@sisk.pl>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [patch] CPU hotplug: call check_tsc_sync_source() with irqs off
Date: Wed, 7 Mar 2007 18:12:31 +0100 [thread overview]
Message-ID: <20070307171230.GA21593@elte.hu> (raw)
In-Reply-To: <Pine.LNX.4.64.0703070827490.5963@woody.linux-foundation.org>
* Linus Torvalds <torvalds@linux-foundation.org> wrote:
> [ Ingo and Thomas added to Cc, because I think this is them.. ]
>
> Ingo, I think this came in during commit 95492e4646, "x86: rewrite SMP
> TSC sync code".
yeah.
> > I get this while
> > echo shutdown > /sys/power/disk; echo disk > /sys/power/state
> >
> > BUG: using smp_processor_id() in preemptible [00000001] code: swsusp_shutdown/3359
> > caller is check_tsc_sync_source+0x1b/0xef
Michal, could you try the patch below?
Ingo
----------------------------->
Subject: [patch] CPU hotplug: call check_tsc_sync_source() with irqs off
From: Ingo Molnar <mingo@elte.hu>
check_tsc_sync_source() depends on being called with irqs disabled (it
checks whether the TSC is coherent across two specific CPUs). This is
incidentally true during bootup, but not during cpu hotplug __cpu_up().
This got found via smp_processor_id() debugging.
disable irqs explicitly and remove the unconditional enabling of
interrupts. Add touch_nmi_watchdog() to the cpu_online_map busy loop.
this bug is present both on i386 and on x86_64.
Reported-by: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/i386/kernel/smpboot.c | 16 ++++++++++------
arch/x86_64/kernel/smpboot.c | 5 ++++-
2 files changed, 14 insertions(+), 7 deletions(-)
Index: linux/arch/i386/kernel/smpboot.c
===================================================================
--- linux.orig/arch/i386/kernel/smpboot.c
+++ linux/arch/i386/kernel/smpboot.c
@@ -50,6 +50,7 @@
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/percpu.h>
+#include <linux/nmi.h>
#include <linux/delay.h>
#include <linux/mc146818rtc.h>
@@ -1283,8 +1284,9 @@ void __cpu_die(unsigned int cpu)
int __cpuinit __cpu_up(unsigned int cpu)
{
+ unsigned long flags;
#ifdef CONFIG_HOTPLUG_CPU
- int ret=0;
+ int ret = 0;
/*
* We do warm boot only on cpus that had booted earlier
@@ -1302,23 +1304,25 @@ int __cpuinit __cpu_up(unsigned int cpu)
/* In case one didn't come up */
if (!cpu_isset(cpu, cpu_callin_map)) {
printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu);
- local_irq_enable();
return -EIO;
}
- local_irq_enable();
-
per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
/* Unleash the CPU! */
cpu_set(cpu, smp_commenced_mask);
/*
- * Check TSC synchronization with the AP:
+ * Check TSC synchronization with the AP (keep irqs disabled
+ * while doing so):
*/
+ local_irq_save(flags);
check_tsc_sync_source(cpu);
+ local_irq_restore(flags);
- while (!cpu_isset(cpu, cpu_online_map))
+ while (!cpu_isset(cpu, cpu_online_map)) {
cpu_relax();
+ touch_nmi_watchdog();
+ }
#ifdef CONFIG_X86_GENERICARCH
if (num_online_cpus() > 8 && genapic == &apic_default)
Index: linux/arch/x86_64/kernel/smpboot.c
===================================================================
--- linux.orig/arch/x86_64/kernel/smpboot.c
+++ linux/arch/x86_64/kernel/smpboot.c
@@ -923,8 +923,9 @@ void __init smp_prepare_boot_cpu(void)
*/
int __cpuinit __cpu_up(unsigned int cpu)
{
- int err;
int apicid = cpu_present_to_apicid(cpu);
+ unsigned long flags;
+ int err;
WARN_ON(irqs_disabled());
@@ -958,7 +959,9 @@ int __cpuinit __cpu_up(unsigned int cpu)
/*
* Make sure and check TSC sync:
*/
+ local_irq_save(flags);
check_tsc_sync_source(cpu);
+ local_irq_restore(flags);
while (!cpu_isset(cpu, cpu_online_map))
cpu_relax();
next prev parent reply other threads:[~2007-03-07 17:13 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 4:59 Linux v2.6.21-rc3 Linus Torvalds
2007-03-07 10:25 ` Benjamin Herrenschmidt
2007-03-07 13:26 ` Greg KH
2007-03-07 14:15 ` Mark Lord
2007-03-07 14:22 ` Greg KH
2007-03-07 15:39 ` Linus Torvalds
2007-03-07 20:52 ` Arnd Bergmann
2007-03-08 8:10 ` Benjamin Herrenschmidt
2007-03-08 8:08 ` Benjamin Herrenschmidt
2007-03-07 12:56 ` Michal Piotrowski
2007-03-07 16:34 ` Linus Torvalds
2007-03-07 17:12 ` Ingo Molnar [this message]
2007-03-07 17:45 ` [patch] CPU hotplug: call check_tsc_sync_source() with irqs off Michal Piotrowski
2007-03-07 19:12 ` Linux-2.6.21-rc3 : Dynticks and High resolution Timer hanging the system Stephane Casset
2007-03-07 19:52 ` Thomas Gleixner
2007-03-07 21:16 ` Stephane Casset
2007-03-07 22:09 ` Thomas Gleixner
2007-03-07 13:09 ` Linux v2.6.21-rc3 Michal Piotrowski
2007-03-07 16:25 ` Linus Torvalds
2007-03-07 17:14 ` [Linux-parport] " Stephen Mollett
2007-03-07 17:35 ` Russell King
2007-03-07 14:22 ` Thomas Gleixner
2007-03-07 17:14 ` Thomas Gleixner
2007-03-07 17:42 ` Soeren Sonnenburg
2007-03-08 17:28 ` Alistair John Strachan
2007-03-13 12:49 ` [1/6] 2.6.21-rc3: known regressions Adrian Bunk
2007-03-13 13:08 ` Pierre Ossman
2007-03-13 13:36 ` Oliver Neukum
2007-03-13 18:11 ` Pavel Machek
2007-03-13 19:07 ` Pierre Ossman
2007-03-13 19:12 ` Mws
2007-03-13 19:15 ` Adrian Bunk
2007-03-13 20:05 ` Pavel Machek
2007-03-13 20:31 ` Pierre Ossman
2007-03-13 13:40 ` Takashi Iwai
2007-03-13 12:50 ` [2/6] " Adrian Bunk
2007-03-13 13:30 ` Cornelia Huck
2007-03-13 13:35 ` Mark Lord
2007-03-13 18:13 ` Pavel Machek
2007-03-13 12:50 ` [3/6] " Adrian Bunk
2007-03-13 14:03 ` Alan Cox
2007-03-13 20:12 ` Fabio Comolli
2007-03-13 15:13 ` Andi Kleen
2007-03-13 12:50 ` [4/6] " Adrian Bunk
2007-03-13 12:50 ` [5/6] " Adrian Bunk
2007-03-13 13:29 ` Lukas Hejtmanek
2007-03-13 18:14 ` Pavel Machek
2007-03-13 21:46 ` Arkadiusz Miskiewicz
2007-03-13 12:50 ` [6/6] " Adrian Bunk
2007-03-13 20:05 ` Thomas Gleixner
2007-03-14 11:31 ` Adrian Bunk
2007-03-13 20:46 ` Thomas Gleixner
2007-03-14 11:44 ` Adrian Bunk
2007-03-14 12:16 ` Jiri Slaby
2007-03-14 17:31 ` Adrian Bunk
2007-03-14 18:02 ` Florian Lohoff
2007-03-14 18:28 ` Thomas Gleixner
2007-03-13 19:26 ` Linux v2.6.21-rc3 Eric W. Biederman
2007-03-13 19:40 ` Greg KH
2007-03-13 19:48 ` Linus Torvalds
2007-03-13 20:04 ` Eric W. Biederman
2007-03-14 18:11 ` 2.6.21-rc3: known regressions with patches Adrian Bunk
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=20070307171230.GA21593@elte.hu \
--to=mingo@elte.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.k.k.piotrowski@gmail.com \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).