[patch] CPU hotplug: call check_tsc_sync_source() with irqs off

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Michal Piotrowski <michal.k.k.piotrowski@...>, Linux Kernel Mailing List <linux-kernel@...>, Pavel Machek <pavel@...>, Rafael J. Wysocki <rjw@...>, Thomas Gleixner <tglx@...>
Date: Wednesday, March 7, 2007 - 1:12 pm

* Linus Torvalds <torvalds@linux-foundation.org> wrote:


yeah.


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();
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Linux v2.6.21-rc3, Linus Torvalds, (Wed Mar 7, 12:59 am)
2.6.21-rc3: known regressions with patches, Adrian Bunk, (Wed Mar 14, 2:11 pm)
Re: Linux v2.6.21-rc3, Eric W. Biederman, (Tue Mar 13, 3:26 pm)
Re: Linux v2.6.21-rc3, Greg KH, (Tue Mar 13, 3:40 pm)
Re: Linux v2.6.21-rc3, Eric W. Biederman, (Tue Mar 13, 4:04 pm)
Re: Linux v2.6.21-rc3, Linus Torvalds, (Tue Mar 13, 3:48 pm)
[3/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:50 am)
Re: [3/6] 2.6.21-rc3: known regressions, Andi Kleen, (Tue Mar 13, 11:13 am)
Re: [3/6] 2.6.21-rc3: known regressions, Alan Cox, (Tue Mar 13, 10:03 am)
Re: [3/6] 2.6.21-rc3: known regressions, Fabio Comolli, (Tue Mar 13, 4:12 pm)
[2/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:50 am)
Re: [2/6] 2.6.21-rc3: known regressions, Cornelia Huck, (Tue Mar 13, 9:30 am)
Re: [2/6] 2.6.21-rc3: known regressions, Mark Lord, (Tue Mar 13, 9:35 am)
Re: [2/6] 2.6.21-rc3: known regressions, Pavel Machek, (Tue Mar 13, 2:13 pm)
[6/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:50 am)
Re: [6/6] 2.6.21-rc3: known regressions, Thomas Gleixner, (Tue Mar 13, 4:46 pm)
Re: [6/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Wed Mar 14, 7:44 am)
Re: [6/6] 2.6.21-rc3: known regressions, Florian Lohoff, (Wed Mar 14, 2:02 pm)
Re: [6/6] 2.6.21-rc3: known regressions, Thomas Gleixner, (Wed Mar 14, 2:28 pm)
Re: [6/6] 2.6.21-rc3: known regressions, Jiri Slaby, (Wed Mar 14, 8:16 am)
Re: [6/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Wed Mar 14, 1:31 pm)
Re: [6/6] 2.6.21-rc3: known regressions, Thomas Gleixner, (Tue Mar 13, 4:05 pm)
Re: [6/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Wed Mar 14, 7:31 am)
[5/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:50 am)
Re: [5/6] 2.6.21-rc3: known regressions, Arkadiusz Miskiewicz, (Tue Mar 13, 5:46 pm)
Re: [5/6] 2.6.21-rc3: known regressions, Pavel Machek, (Tue Mar 13, 2:14 pm)
Re: [5/6] 2.6.21-rc3: known regressions, Lukas Hejtmanek, (Tue Mar 13, 9:29 am)
[4/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:50 am)
[1/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 8:49 am)
Re: [1/6] 2.6.21-rc3: known regressions, Takashi Iwai, (Tue Mar 13, 9:40 am)
Re: [1/6] 2.6.21-rc3: known regressions, Pierre Ossman, (Tue Mar 13, 9:08 am)
Re: [1/6] 2.6.21-rc3: known regressions, Oliver Neukum, (Tue Mar 13, 9:36 am)
Re: [1/6] 2.6.21-rc3: known regressions, Pavel Machek, (Tue Mar 13, 2:11 pm)
Re: [1/6] 2.6.21-rc3: known regressions, Pierre Ossman, (Tue Mar 13, 3:07 pm)
Re: [1/6] 2.6.21-rc3: known regressions, Pavel Machek, (Tue Mar 13, 4:05 pm)
Re: [1/6] 2.6.21-rc3: known regressions, Pierre Ossman, (Tue Mar 13, 4:31 pm)
Re: [1/6] 2.6.21-rc3: known regressions, Adrian Bunk, (Tue Mar 13, 3:15 pm)
Re: [1/6] 2.6.21-rc3: known regressions, Mws, (Tue Mar 13, 3:12 pm)
Re: Linux v2.6.21-rc3, Alistair John Strachan, (Thu Mar 8, 1:28 pm)
Re: Linux v2.6.21-rc3, Thomas Gleixner, (Wed Mar 7, 10:22 am)
Re: Linux v2.6.21-rc3, Soeren Sonnenburg, (Wed Mar 7, 1:42 pm)
Re: Linux v2.6.21-rc3, Thomas Gleixner, (Wed Mar 7, 1:14 pm)
Re: Linux v2.6.21-rc3, Michal Piotrowski, (Wed Mar 7, 9:09 am)
Re: [Linux-parport] Linux v2.6.21-rc3, Stephen Mollett, (Wed Mar 7, 1:14 pm)
Re: [Linux-parport] Linux v2.6.21-rc3, Russell King, (Wed Mar 7, 1:35 pm)
Re: Linux v2.6.21-rc3, Linus Torvalds, (Wed Mar 7, 12:25 pm)
Re: Linux v2.6.21-rc3, Michal Piotrowski, (Wed Mar 7, 8:56 am)
Re: Linux v2.6.21-rc3, Linus Torvalds, (Wed Mar 7, 12:34 pm)
[patch] CPU hotplug: call check_tsc_sync_source() with irqs ..., Ingo Molnar, (Wed Mar 7, 1:12 pm)
Re: Linux v2.6.21-rc3, Benjamin Herrenschmidt, (Wed Mar 7, 6:25 am)
Re: Linux v2.6.21-rc3, Linus Torvalds, (Wed Mar 7, 11:39 am)
Re: Linux v2.6.21-rc3, Benjamin Herrenschmidt, (Thu Mar 8, 4:08 am)
Re: Linux v2.6.21-rc3, Arnd Bergmann, (Wed Mar 7, 4:52 pm)
Re: Linux v2.6.21-rc3, Benjamin Herrenschmidt, (Thu Mar 8, 4:10 am)
Re: Linux v2.6.21-rc3, Greg KH, (Wed Mar 7, 9:26 am)
Re: Linux v2.6.21-rc3, Mark Lord, (Wed Mar 7, 10:15 am)
Re: Linux v2.6.21-rc3, Greg KH, (Wed Mar 7, 10:22 am)