powerpc/crash: Use NMI context for printk when starting to crash
PATCH v3 1/1 powerpc/crash: Use NMI context for printk when starting to crash
Currently, if printk lock (logbuf_lock) is held by other thread during crash, there is a chance of deadlocking the crash on next printk, and blocking a possibly desired kdump.
At the start of default_machine_crash_shutdown, make printk enter NMI context, as it will use per-cpu buffers to store the message, and avoid locking logbuf_lock.
---
Changes since v2:
- Changes usage of printk_nmi_enter() to nmi_enter() (Suggested by Nick Piggin)
Changes since v1:
- Added in-code comment explaining the need of context change
- Function moved to the start of default_machine_crash_shutdown, to avoid locking any printk on crashing routine.
- Title was 'Use NMI context for printk after crashing other CPUs'
--- arch/powerpc/kexec/crash.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/kexec/crash.c +8 -0
@@ -16,6 +16,7 @@#include <linux/delay.h> #include <linux/irq.h> #include <linux/types.h> +#include <linux/hardirq.h> #include <asm/processor.h> #include <asm/machdep.h>
@@ -311,6 +312,13 @@ void default_machine_crash_shutdown(struct pt_regs *regs)unsigned int i;int (*old_handler)(struct pt_regs *regs); +/* +* Avoid hardlocking with irresponsive CPU holding logbuf_lock, +* by using printk nmi_context +*/ +if (!in_nmi ()) +nmi_enter (); +/* * This function is only called after the system * has panicked or is otherwise in a critical state.
Signature · 1 line
2.25.4