powerpc/crash: Use NMI context for printk after crashing other CPUs
PATCH 1/1 powerpc/crash: Use NMI context for printk after crashing other CPUs
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.
After sending IPI to all other CPUs, make printk enter in NMI context, as it will use per-cpu buffers to store the message, and avoid locking logbuf_lock.
--- arch/powerpc/kexec/crash.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kexec/crash.c +1 -0
@@ -115,6 +115,7 @@ static void crash_kexec_prepare_cpus(int cpu)crash_send_ipi (crash_ipi_callback);smp_wmb (); +printk_nmi_enter (); again:/*
Signature · 1 line
2.25.1
Michael Ellerman
reviewerarch/powerpc/kexec/crash.c static void crash_kexec_prepare_cpus(int cpu)
Quoted 18 lines · Leonardo Bras
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.After sending IPI to all other CPUs, make printk enter in NMI context, as it will use per-cpu buffers to store the message, and avoid locking
logbuf_lock.Signed-off-by Leonardo Bras <[email protected]>--- arch/powerpc/kexec/crash.c | 1 + 1 file changed, 1 insertion(+)arch/powerpc/kexec/crash.c +0
-0@@ -115,6 +115,7 @@ static void crash_kexec_prepare_cpus(int cpu)
Added context:
printk(KERN_EMERG "Sending IPI to other CPUs\n"); if (crash_wake_offline) ncpus = num_present_cpus() - 1;
arch/powerpc/kexec/crash.c static void crash_kexec_prepare_cpus(int cpu) · line 118
Quoted 4 lines
arch/powerpc/kexec/crash.c +1
-0crash_send_ipi (crash_ipi_callback);smp_wmb (); +printk_nmi_enter ();
Why did you decide to put it there, rather than at the start of default_machine_crash_shutdown() like I did?
The printk() above could have already deadlocked if another CPU is stuck with the logbuf lock held.
cheers
On Wed, 2020-04-08 at 22:13 +1000, Michael Ellerman wrote:
[...]
Quoted 15 lines
Added context:
printk(KERN_EMERG "Sending IPI to other CPUs\n"); if (crash_wake_offline) ncpus = num_present_cpus() - 1;arch/powerpc/kexec/crash.c static void crash_kexec_prepare_cpus(int cpu) · line 118
Quoted 4 lines
arch/powerpc/kexec/crash.c +1
-0crash_send_ipi (crash_ipi_callback);smp_wmb (); +printk_nmi_enter ();Why did you decide to put it there, rather than at the start of
default_machine_crash_shutdown()like I did?
Quoted 2 lines
The
printk()above could have already deadlocked if another CPU is stuck with the logbuf lock held.
Oh, I thought the CPUs would start crashing after crash_send_ipi(), so only printk() after that would possibly deadlock.
I was not able to see how the printk() above would deadlock, but I see no problem adding that at the start of the function.
Best regards,
Leonardo Bras