powerpc: NMI IPI make NMI IPIs fully sychronous
Nicholas Piggin
reviewerPATCH v2 1/1 powerpc: NMI IPI make NMI IPIs fully sychronous
There is an asynchronous aspect to smp_send_nmi_ipi. The caller waits for all CPUs to call in to the handler, but it does not wait for completion of the handler. This is a needless complication, so remove it and always wait synchronously.
The synchronous wait allows the caller to easily time out and clear the wait for completion (zero nmi_ipi_busy_count) in the case of badly behaved handlers. This would have prevented the recent smp_send_stop NMI IPI bug from causing the system to hang.
---
Changes since v2:
- Fixed a locking bug in the timeout path
- Move all the shared memory accesses under the lock to avoid worrys about memory ordering.
arch/powerpc/include/asm/smp.h | 1 - arch/powerpc/kernel/smp.c | 52 ++++++++++++++++++---------------- arch/powerpc/kernel/watchdog.c | 1 - 3 files changed, 28 insertions(+), 26 deletions(-)
arch/powerpc/include/asm/smp.h +0 -1
@@ -56,7 +56,6 @@ struct smp_ops_t {int (*cpu_bootable)(unsigned int nr); }; -extern void smp_flush_nmi_ipi (u64 delay_us);extern int smp_send_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern void smp_send_debugger_break (void );extern void start_secondary_resume (void );
arch/powerpc/kernel/smp.c +27 -23
90 lines not on this page · raw message
arch/powerpc/kernel/watchdog.c +0 -1
@@ -165,7 +165,6 @@ static void watchdog_smp_panic(int cpu, u64 tb)continue ;smp_send_nmi_ipi (c, wd_lockup_ipi,1000000 ); } -smp_flush_nmi_ipi (1000000 ); }/* Take the stuck CPUs out of the watch group */
Signature · 1 line
2.17.0
Michael Ellerman
AppliedQuoted 11 lines · Nicholas Piggin
There is an asynchronous aspect to
smp_send_nmi_ipi. The caller waits for all CPUs to call in to the handler, but it does not wait for completion of the handler. This is a needless complication, so remove it and always wait synchronously.The synchronous wait allows the caller to easily time out and clear the wait for completion (zero
nmi_ipi_busy_count) in the case of badly behaved handlers. This would have prevented the recentsmp_send_stopNMI IPI bug from causing the system to hang.Signed-off-by Nicholas Piggin <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/5b73151fff63fb019db8171cb81c6c
cheers