LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/1] powerpc/crash: Use NMI context for printk after crashing other CPUs
@ 2020-04-06 17:40 Leonardo Bras
2020-04-08 12:13 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Leonardo Bras @ 2020-04-06 17:40 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Greg Kroah-Hartman, Enrico Weigelt, Thomas Gleixner,
Allison Randal, Christophe Leroy, Leonardo Bras, Nicholas Piggin
Cc: linuxppc-dev, linux-kernel
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 <leonardo@linux.ibm.com>
---
arch/powerpc/kexec/crash.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c
index d488311efab1..9b73e3991bf4 100644
--- a/arch/powerpc/kexec/crash.c
+++ b/arch/powerpc/kexec/crash.c
@@ -115,6 +115,7 @@ static void crash_kexec_prepare_cpus(int cpu)
crash_send_ipi(crash_ipi_callback);
smp_wmb();
+ printk_nmi_enter();
again:
/*
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] powerpc/crash: Use NMI context for printk after crashing other CPUs
2020-04-06 17:40 [PATCH 1/1] powerpc/crash: Use NMI context for printk after crashing other CPUs Leonardo Bras
@ 2020-04-08 12:13 ` Michael Ellerman
2020-04-08 18:41 ` Leonardo Bras
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2020-04-08 12:13 UTC (permalink / raw)
To: Leonardo Bras, Benjamin Herrenschmidt, Paul Mackerras,
Greg Kroah-Hartman, Enrico Weigelt, Thomas Gleixner,
Allison Randal, Christophe Leroy, Leonardo Bras, Nicholas Piggin
Cc: linuxppc-dev, linux-kernel
Leonardo Bras <leonardo@linux.ibm.com> writes:
> 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 <leonardo@linux.ibm.com>
> ---
> arch/powerpc/kexec/crash.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c
> index d488311efab1..9b73e3991bf4 100644
> --- a/arch/powerpc/kexec/crash.c
> +++ b/arch/powerpc/kexec/crash.c
> @@ -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;
>
> crash_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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] powerpc/crash: Use NMI context for printk after crashing other CPUs
2020-04-08 12:13 ` Michael Ellerman
@ 2020-04-08 18:41 ` Leonardo Bras
0 siblings, 0 replies; 3+ messages in thread
From: Leonardo Bras @ 2020-04-08 18:41 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Greg Kroah-Hartman, Enrico Weigelt, Thomas Gleixner,
Allison Randal, Christophe Leroy, Nicholas Piggin
Cc: linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 827 bytes --]
On Wed, 2020-04-08 at 22:13 +1000, Michael Ellerman wrote:
[...]
> Added context:
>
> printk(KERN_EMERG "Sending IPI to other CPUs\n");
>
> if (crash_wake_offline)
> ncpus = num_present_cpus() - 1;
>
> >
> > crash_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.
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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-08 18:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 17:40 [PATCH 1/1] powerpc/crash: Use NMI context for printk after crashing other CPUs Leonardo Bras
2020-04-08 12:13 ` Michael Ellerman
2020-04-08 18:41 ` Leonardo Bras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).