]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86, kexec: Make sure to stop all CPUs before exiting the kernel
authorAlok Kataria <akataria@vmware.com>
Mon, 11 Oct 2010 21:37:08 +0000 (14:37 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Mar 2011 19:43:30 +0000 (12:43 -0700)
commit 76fac077db6b34e2c6383a7b4f3f4f7b7d06d8ce upstream.

x86 smp_ops now has a new op, stop_other_cpus which takes a parameter
"wait" this allows the caller to specify if it wants to stop until all
the cpus have processed the stop IPI.  This is required specifically
for the kexec case where we should wait for all the cpus to be stopped
before starting the new kernel.  We now wait for the cpus to stop in
all cases except for panic/kdump where we expect things to be broken
and we are doing our best to make things work anyway.

This patch fixes a legitimate regression, which was introduced during
2.6.30, by commit id 4ef702c10b5df18ab04921fc252c26421d4d6c75.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
LKML-Reference: <1286833028.1372.20.camel@ank32.eng.vmware.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/include/asm/smp.h
arch/x86/kernel/reboot.c
arch/x86/kernel/smp.c
arch/x86/xen/enlighten.c
arch/x86/xen/smp.c

index 4cfc908240684c561b4554281c36850643fc139f..4c2f63c7fc1b2ec071d3d32465f389a6d9df24dd 100644 (file)
@@ -50,7 +50,7 @@ struct smp_ops {
        void (*smp_prepare_cpus)(unsigned max_cpus);
        void (*smp_cpus_done)(unsigned max_cpus);
 
-       void (*smp_send_stop)(void);
+       void (*stop_other_cpus)(int wait);
        void (*smp_send_reschedule)(int cpu);
 
        int (*cpu_up)(unsigned cpu);
@@ -73,7 +73,12 @@ extern struct smp_ops smp_ops;
 
 static inline void smp_send_stop(void)
 {
-       smp_ops.smp_send_stop();
+       smp_ops.stop_other_cpus(0);
+}
+
+static inline void stop_other_cpus(void)
+{
+       smp_ops.stop_other_cpus(1);
 }
 
 static inline void smp_prepare_boot_cpu(void)
index 8e1aac86b50c6dcce26df41a1728ea21cf2a54e8..ff8cc40276e496ad6dffb0779f4478d136ee51b9 100644 (file)
@@ -633,7 +633,7 @@ void native_machine_shutdown(void)
        /* O.K Now that I'm on the appropriate processor,
         * stop all of the others.
         */
-       smp_send_stop();
+       stop_other_cpus();
 #endif
 
        lapic_shutdown();
index ec1de97600e70638bcfdcb53da52a83bc1288829..29f0a78ec88743a59f29770d067fc4880ec36656 100644 (file)
@@ -158,10 +158,10 @@ asmlinkage void smp_reboot_interrupt(void)
        irq_exit();
 }
 
-static void native_smp_send_stop(void)
+static void native_stop_other_cpus(int wait)
 {
        unsigned long flags;
-       unsigned long wait;
+       unsigned long timeout;
 
        if (reboot_force)
                return;
@@ -178,9 +178,12 @@ static void native_smp_send_stop(void)
        if (num_online_cpus() > 1) {
                apic->send_IPI_allbutself(REBOOT_VECTOR);
 
-               /* Don't wait longer than a second */
-               wait = USEC_PER_SEC;
-               while (num_online_cpus() > 1 && wait--)
+               /*
+                * Don't wait longer than a second if the caller
+                * didn't ask us to wait.
+                */
+               timeout = USEC_PER_SEC;
+               while (num_online_cpus() > 1 && (wait || timeout--))
                        udelay(1);
        }
 
@@ -226,7 +229,7 @@ struct smp_ops smp_ops = {
        .smp_prepare_cpus       = native_smp_prepare_cpus,
        .smp_cpus_done          = native_smp_cpus_done,
 
-       .smp_send_stop          = native_smp_send_stop,
+       .stop_other_cpus        = native_stop_other_cpus,
        .smp_send_reschedule    = native_smp_send_reschedule,
 
        .cpu_up                 = native_cpu_up,
index b607239c1ba8304f2732f0e7035a81f2ee1bff8c..821dc579391a229c2d41ed3bbc2169a68448ad89 100644 (file)
@@ -1000,7 +1000,7 @@ static void xen_reboot(int reason)
        struct sched_shutdown r = { .reason = reason };
 
 #ifdef CONFIG_SMP
-       smp_send_stop();
+       stop_other_cpus();
 #endif
 
        if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
index 563d20504988ef7671cf600cdc2762f00418a4c8..ad5df678335e8772e389ce6c0397d5eff8af1284 100644 (file)
@@ -397,9 +397,9 @@ static void stop_self(void *v)
        BUG();
 }
 
-static void xen_smp_send_stop(void)
+static void xen_stop_other_cpus(int wait)
 {
-       smp_call_function(stop_self, NULL, 0);
+       smp_call_function(stop_self, NULL, wait);
 }
 
 static void xen_smp_send_reschedule(int cpu)
@@ -467,7 +467,7 @@ static const struct smp_ops xen_smp_ops __initdata = {
        .cpu_disable = xen_cpu_disable,
        .play_dead = xen_play_dead,
 
-       .smp_send_stop = xen_smp_send_stop,
+       .stop_other_cpus = xen_stop_other_cpus,
        .smp_send_reschedule = xen_smp_send_reschedule,
 
        .send_call_func_ipi = xen_smp_send_call_function_ipi,