linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kexec: force x86_64 arches to boot kdump kernels on boot cpu
@ 2007-11-27  1:47 Neil Horman
  2007-11-27  4:12 ` Eric W. Biederman
  2007-11-27 10:55 ` Andi Kleen
  0 siblings, 2 replies; 100+ messages in thread
From: Neil Horman @ 2007-11-27  1:47 UTC (permalink / raw)
  To: kexec; +Cc: ak, vgoyal, hbabu, linux-kernel, ebiederm, nhorman

Hey all-
	I've been working on an issue lately involving multi socket x86_64
systems connected via hypertransport bridges.  It appears that some systems,
disable the hypertransport connections during a kdump operation when all but the
crashing processor gets halted in machine_crash_shutdown.  This becomes a
problem when the ioapic attempts to route interrupts to the only remaining
processor.  Even though the active processor is targeted for interrupt
reception, the fact that the hypertransport connections are inactive result in
interrupts not getting delivered.  The effective result is that timer interrupts
are not delivered to the running cpu, and the system hangs on reboot into the
kdump kernel during calibrate_delay.  I've found that I've been able to avoid
this hang, by forcing a transition to the bios defined boot cpu during the
crashing kernel shutdown.  This patch accomplished that.  Tested by myself and
the origional reporter with successful results.

Regards,
Neil

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 arch/x86/kernel/crash.c |   46 ++++++++++++++++++++++++++++++++++++++--------
 include/linux/kexec.h   |    3 +++
 init/main.c             |    6 ++++++
 kernel/kexec.c          |    8 ++++++++
 4 files changed, 55 insertions(+), 8 deletions(-)


diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 8bb482f..0682e60 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -67,13 +67,36 @@ static int crash_nmi_callback(struct notifier_block *self,
 	}
 #endif
 	crash_save_cpu(regs, cpu);
-	disable_local_APIC();
-	atomic_dec(&waiting_for_crash_ipi);
-	/* Assume hlt works */
-	halt();
-	for (;;)
-		cpu_relax();
-
+	if (smp_processor_id() == kexec_boot_cpu) {
+		/*
+		 * This is the boot cpu.  We need to:
+		 * 1) Wait for the other processors to halt
+		 * 2) clear our nmi interrupt
+		 * 3) launch the new kernel
+		 */
+		unsigned long msecs = 1000;
+		while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
+			/*
+			 * Use udelay to avoid the warnings here
+			 * I know we shouldn't delay in an irq
+			 * but we're about to reboot the box during
+			 * a crash, a delay doesn't hurt here
+			 */
+			udelay(1000);
+			msecs--;
+		}
+		ack_APIC_irq(); 
+		disable_local_APIC();
+		disable_IO_APIC();
+		machine_kexec(kexec_crash_image);
+
+	} else {
+		disable_local_APIC();
+		atomic_dec(&waiting_for_crash_ipi);
+		/* Assume hlt works */
+		for(;;)
+			halt();
+	}
 	return 1;
 }
 
@@ -138,7 +161,14 @@ void machine_crash_shutdown(struct pt_regs *regs)
 	nmi_shootdown_cpus();
 	lapic_shutdown();
 #if defined(CONFIG_X86_IO_APIC)
-	disable_IO_APIC();
+	if (crashing_cpu == kexec_boot_cpu) 
+		disable_IO_APIC();
 #endif
 	crash_save_cpu(regs, safe_smp_processor_id());
+	if (crashing_cpu != kexec_boot_cpu) {
+		atomic_dec(&waiting_for_crash_ipi);
+		for(;;)
+			halt();
+	}
+
 }
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 2d9c448..b5c12d6 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -187,6 +187,9 @@ extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
 extern size_t vmcoreinfo_size;
 extern size_t vmcoreinfo_max_size;
 
+extern int kexec_boot_cpu;
+extern void kexec_record_boot_cpu();
+
 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
 		unsigned long long *crash_size, unsigned long long *crash_base);
 
diff --git a/init/main.c b/init/main.c
index 58f5a99..0f11ee0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -58,6 +58,9 @@
 #include <linux/kthread.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
+#ifdef CONFIG_KEXEC
+#include <linux/kexec.h>
+#endif
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -538,6 +541,9 @@ asmlinkage void __init start_kernel(void)
 	unwind_setup();
 	setup_per_cpu_areas();
 	smp_prepare_boot_cpu();	/* arch-specific boot-cpu hooks */
+#ifdef CONFIG_KEXEC
+	kexec_record_boot_cpu();
+#endif
 
 	/*
 	 * Set up the scheduler prior starting any interrupts (such as the
diff --git a/kernel/kexec.c b/kernel/kexec.c
index aa74a1e..cb6b1f3 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -41,6 +41,14 @@ u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
 size_t vmcoreinfo_size;
 size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
 
+int kexec_boot_cpu = 0;
+
+void __init kexec_record_boot_cpu()
+{
+	kexec_boot_cpu = smp_processor_id();
+	printk(KERN_CRIT "kexec records boot cpu as %d\n",kexec_boot_cpu);
+}
+
 /* Location of the reserved area for the crash kernel */
 struct resource crashk_res = {
 	.name  = "Crash kernel",

^ permalink raw reply related	[flat|nested] 100+ messages in thread

end of thread, other threads:[~2007-12-18  0:23 UTC | newest]

Thread overview: 100+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-27  1:47 [PATCH] kexec: force x86_64 arches to boot kdump kernels on boot cpu Neil Horman
2007-11-27  4:12 ` Eric W. Biederman
2007-11-27 13:13   ` Neil Horman
2007-11-27 13:28     ` Eric W. Biederman
2007-11-27 13:45       ` Andi Kleen
2007-11-27 14:28         ` Neil Horman
2007-11-27 14:43           ` Andi Kleen
2007-11-27 14:48             ` Neil Horman
2007-11-27 15:24               ` Andi Kleen
2007-11-27 15:30               ` Eric W. Biederman
2007-11-27 16:45                 ` Neil Horman
2007-11-27 20:50                 ` Ben Woodard
2007-11-27 21:05                   ` Neil Horman
2007-11-27 22:38                     ` Eric W. Biederman
2007-11-27 23:15                       ` Ben Woodard
2007-11-28  0:15                         ` Eric W. Biederman
2007-11-27 23:40                       ` Neil Horman
2007-11-28  0:43                         ` Eric W. Biederman
2007-11-28 15:54                     ` Neil Horman
2007-11-27 14:56         ` Eric W. Biederman
2007-11-27 15:34           ` Neil Horman
2007-11-27 18:41           ` Ben Woodard
2007-11-27 19:42             ` Neil Horman
2007-11-27 20:00               ` Vivek Goyal
2007-11-27 20:52                 ` Neil Horman
2007-11-27 22:24                 ` Andi Kleen
2007-11-27 23:24                   ` Ben Woodard
2007-11-27 23:56                     ` Andi Kleen
2007-11-28 15:36                     ` Vivek Goyal
2007-11-28 16:02                       ` Neil Horman
2007-11-28 17:36                         ` Eric W. Biederman
2007-11-28 18:16                           ` Neil Horman
2007-11-28 19:05                         ` Vivek Goyal
2007-11-28 19:42                           ` Eric W. Biederman
2007-11-28 21:09                             ` Neil Horman
2007-11-28 23:27                               ` Eric W. Biederman
2007-11-30  2:16                             ` Ben Woodard
2007-11-30  2:54                               ` Eric W. Biederman
2007-11-30  8:59                                 ` Yinghai Lu
2007-11-30 14:35                                   ` Vivek Goyal
2007-11-30 14:32                                 ` Neil Horman
2007-11-30  2:12                           ` Ben Woodard
2007-11-30 14:42                             ` Vivek Goyal
2007-11-30 14:51                               ` Neil Horman
2007-12-06 21:39                                 ` Neil Horman
2007-12-06 22:11                                   ` Vivek Goyal
2007-12-07  0:10                                     ` Neil Horman
2007-12-07 14:39                                       ` Vivek Goyal
2007-12-07 14:53                                         ` Neil Horman
2007-12-07 15:16                                           ` Vivek Goyal
2007-12-07 15:53                                             ` Neil Horman
2007-12-07 18:46                                               ` Eric W. Biederman
2007-12-07  0:33                                     ` Eric W. Biederman
2007-12-07  2:04                                       ` Neil Horman
2007-12-07  8:50                                       ` Yinghai Lu
2007-12-07  9:22                                         ` Yinghai Lu
2007-12-07 14:21                                           ` Neil Horman
2007-12-07 17:58                                             ` Neil Horman
2007-12-07 19:19                                               ` yhlu
2007-12-07 20:13                                                 ` Neil Horman
2007-12-10 15:39                                               ` Neil Horman
2007-12-10 16:20                                                 ` Vivek Goyal
2007-12-11  1:17                                                 ` Eric W. Biederman
2007-12-11  1:08                                               ` Eric W. Biederman
2007-12-11  3:43                                                 ` Neil Horman
2007-12-11  4:48                                                   ` Eric W. Biederman
2007-12-11  6:31                                                     ` Yinghai Lu
2007-12-11 14:39                                                     ` Neil Horman
2007-12-11 15:29                                                       ` Eric W. Biederman
2007-12-11 18:00                                                         ` Yinghai Lu
2007-12-11 18:29                                                           ` Neil Horman
2007-12-11 18:45                                                             ` Yinghai Lu
2007-12-11 18:22                                                         ` Neil Horman
2007-12-11 18:46                                                           ` Eric W. Biederman
2007-12-11 19:24                                                             ` Neil Horman
2007-12-11 19:51                                                               ` Yinghai Lu
2007-12-11 20:59                                                                 ` Neil Horman
2007-12-12  0:16                                                                   ` Ben Woodard
2007-12-12  0:52                                                                     ` Neil Horman
2007-12-12  1:07                                                                       ` Yinghai Lu
2007-12-12  8:43                                                                   ` [PATCH] k8: Enable legacy irqs with extended cpu ids Eric W. Biederman
2007-12-12 14:21                                                                   ` [PATCH] kexec: force x86_64 arches to boot kdump kernels on boot cpu Andi Kleen
2007-12-12 15:55                                                                     ` Neil Horman
2007-12-12 16:07                                                                       ` Andi Kleen
2007-12-12 19:43                                                                         ` Eric W. Biederman
2007-12-12 20:22                                                                           ` Neil Horman
2007-12-12 21:32                                                                             ` Eric W. Biederman
2007-12-13 14:39                                                                               ` Neil Horman
2007-12-13 15:16                                                                                 ` Andi Kleen
2007-12-13 15:32                                                                                   ` Neil Horman
2007-12-17 11:38                                                                                     ` Neil Horman
2007-12-18  0:13                                                                                   ` Eric W. Biederman
2007-12-17 15:16                                                                                 ` Ingo Molnar
2007-12-17 15:47                                                                                   ` Neil Horman
2007-12-07 18:36                                             ` Eric W. Biederman
2007-12-07 18:48                                               ` Neil Horman
2007-11-27 13:53       ` Neil Horman
2007-11-27 10:55 ` Andi Kleen
2007-11-27 11:19   ` Eric W. Biederman
2007-11-27 13:28   ` Neil Horman

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).