ARM64: smp: BUG() if smp_send_reschedule() is called for an offline cpu
PATCH 1/1 ARM64: smp: BUG() if smp_send_reschedule() is called for an offline cpu
Based on the 'commit <8b775be35e41b9f> ("ARM: smp:BUG() if smp_send_reschedule() is called for an offline cpu")'
Sending an IPI_RESCHEDULE to an offline CPU is incorrect and potentially bad for both power and stability. On some sub-architectures such as MSM, if a power-collapsed CPU is unexpectedly woken up by an IPI, it will be begin executing without the preparations that would normally happen as part of CPU_UP_PREPARE. If clocks, voltage regulators, or other hardware configuration are not performed, the booting CPU may cause general instability or (at best) poor power performance since the CPU would be powered up but not utilized.
One common cause for such issues is misuse of add_timer_on() or APIs such as queue_work_on() which call it. If proper precautions are not taken to block hotplug while these APIs are called then a race may result in IPIs being sent to CPUs that are already offline.
This same argument could be applied to other IPIs (with the exception of IPI_WAKEUP), but the others are already restricted to only online CPUs by existing mechanisms, so an explicit assertion is not useful.
--- arch/arm64/kernel/smp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/smp.c +1 -0
@@ -898,6 +898,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)void smp_send_reschedule (int cpu) { +BUG_ON (cpu_is_offline (cpu));smp_cross_call (cpumask_of (cpu),IPI_RESCHEDULE ); }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Mark Rutland
reviewerQuoted 2 lines · Venkata Narendra Kumar Gutta
Based on the 'commit <
8b775be35e41b9f> ("ARM: smp:BUG()ifsmp_send_reschedule()is called for an offline cpu")'
This commit does not appear to exist in mainline. Which tree is it in?
Quoted 30 lines
Sending an
IPI_RESCHEDULEto an offline CPU is incorrect and potentially bad for both power and stability. On some sub-architectures such as MSM, if a power-collapsed CPU is unexpectedly woken up by an IPI, it will be begin executing without the preparations that would normally happen as part ofCPU_UP_PREPARE. If clocks, voltage regulators, or other hardware configuration are not performed, the booting CPU may cause general instability or (at best) poor power performance since the CPU would be powered up but not utilized.One common cause for such issues is misuse of
add_timer_on()or APIs such asqueue_work_on()which call it. If proper precautions are not taken to block hotplug while these APIs are called then a race may result in IPIs being sent to CPUs that are already offline.This same argument could be applied to other IPIs (with the exception of
IPI_WAKEUP), but the others are already restricted to only online CPUs by existing mechanisms, so an explicit assertion is not useful.Signed-off-by Matt Wagantall <[email protected]>Signed-off-by Trilok Soni <[email protected]>Signed-off-by Venkata Narendra Kumar Gutta <[email protected]>--- arch/arm64/kernel/smp.c | 1 + 1 file changed, 1 insertion(+)arch/arm64/kernel/smp.c +0
-0
arch/arm64/kernel/smp.c void handle_IPI(int ipinr, struct pt_regs *regs) · line 903
Quoted 6 lines
arch/arm64/kernel/smp.c +1
-0@@ -898,6 +898,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)void smp_send_reschedule (int cpu) { +BUG_ON (cpu_is_offline (cpu));smp_cross_call (cpumask_of (cpu),IPI_RESCHEDULE ); }
Is BUG_ON() appropriate?
Why not WARN_ON() and return?
AFAICT, arm doesn't have this logic today either.
Thanks,
Mark.