ARM: Fix deadlock scenario with smp_send_stop()
PATCH 1/1 ARM: Fix deadlock scenario with smp_send_stop()
If one process calls sys_reboot and that process then stops other CPUs while those CPUs are within a spin_lock() region we can potentially encounter a deadlock scenario like below.
CPU 0 CPU 1
----- -----
spin_lock(my_lock)smp_send_stop()
send_IPI handle_IPI()
disable_preemption/irqs
while(1); <PREEMPT>spin_lock(my_lock) <--- Waits forever
We shouldn't attempt to run any other tasks after we send a stop IPI to a CPU so disable preemption so that the reboot task runs to completion.
---
Unfortunately this won't fix the other problem I mentioned two weeks ago where smp_send_stop races with other CPUs calling cpu_up().
arch/arm/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/kernel/process.c +1 -0
@@ -239,6 +239,7 @@ __setup("reboot=", reboot_setup);void machine_shutdown (void ) { +preempt_disable ();#ifdef CONFIG_SMP smp_send_stop ();#endif
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
Quoted 18 lines · Stephen Boyd
If one process calls
sys_rebootand that process then stops other CPUs while those CPUs are within aspin_lock()region we can potentially encounter a deadlock scenario like below.CPU 0 CPU 1
----- -----
spin_lock(my_lock)smp_send_stop()
send_IPIhandle_IPI()disable_preemption/irqs while(1);<PREEMPT>
spin_lock(my_lock)<--- Waits foreverWe shouldn't attempt to run any other tasks after we send a stop IPI to a CPU so disable preemption so that the reboot task runs to completion.
Quoted 6 lines
Reported-by Sundarajan Srinivasan <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Unfortunately this won't fix the other problem I mentioned two weeks ago where
smp_send_stopraces with other CPUs callingcpu_up().
Any comments?
Quoted 16 lines
arch/arm/kernel/process.c | 1 + 1 file changed, 1 insertion(+)arch/arm/kernel/process.c +1
-0@@ -239,6 +239,7 @@ __setup("reboot=", reboot_setup);void machine_shutdown (void ) { +preempt_disable ();#ifdef CONFIG_SMP smp_send_stop ();#endif
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation