Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9317/1: kexec: Make smp stop calls asynchronous

If a panic is triggered by a hrtimer interrupt all online cpus will be
notified and set offline. But as highlighted by commit 19dbdcb8039c
("smp: Warn on function calls from softirq context") this call should
not be made synchronous with disabled interrupts:

softdog: Initiating panic
Kernel panic - not syncing: Software Watchdog Timer expired
WARNING: CPU: 1 PID: 0 at kernel/smp.c:753 smp_call_function_many_cond
unwind_backtrace:
show_stack
dump_stack_lvl
__warn
warn_slowpath_fmt
smp_call_function_many_cond
smp_call_function
crash_smp_send_stop.part.0
machine_crash_shutdown
__crash_kexec
panic
softdog_fire
__hrtimer_run_queues
hrtimer_interrupt

Make the smp call for machine_crash_nonpanic_core() asynchronous.

Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

authored by

Mårten Lindahl and committed by
Russell King (Oracle)
8922ba71 e6b51532

+13 -1
+13 -1
arch/arm/kernel/machine_kexec.c
··· 94 94 } 95 95 } 96 96 97 + static DEFINE_PER_CPU(call_single_data_t, cpu_stop_csd) = 98 + CSD_INIT(machine_crash_nonpanic_core, NULL); 99 + 97 100 void crash_smp_send_stop(void) 98 101 { 99 102 static int cpus_stopped; 100 103 unsigned long msecs; 104 + call_single_data_t *csd; 105 + int cpu, this_cpu = raw_smp_processor_id(); 101 106 102 107 if (cpus_stopped) 103 108 return; 104 109 105 110 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); 106 - smp_call_function(machine_crash_nonpanic_core, NULL, false); 111 + for_each_online_cpu(cpu) { 112 + if (cpu == this_cpu) 113 + continue; 114 + 115 + csd = &per_cpu(cpu_stop_csd, cpu); 116 + smp_call_function_single_async(cpu, csd); 117 + } 118 + 107 119 msecs = 1000; /* Wait at most a second for the other cpus to stop */ 108 120 while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { 109 121 mdelay(1);