From: Leonardo Bras <leobras.c@gmail.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Allison Randal <allison@lohutok.net>,
Leonardo Bras <leobras.c@gmail.com>,
Christophe Leroy <christophe.leroy@c-s.fr>,
Alexios Zavras <alexios.zavras@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Nicholas Piggin <npiggin@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 1/1] powerpc/crash: Use NMI context for printk when starting to crash
Date: Mon, 18 May 2020 21:25:58 -0300 [thread overview]
Message-ID: <20200519002558.202929-1-leobras.c@gmail.com> (raw)
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.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Leonardo Bras <leobras.c@gmail.com>
---
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(+)
diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c
index d488311efab1..53c5cf9b6d3c 100644
--- a/arch/powerpc/kexec/crash.c
+++ b/arch/powerpc/kexec/crash.c
@@ -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.
--
2.25.4
reply other threads:[~2020-05-19 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519002558.202929-1-leobras.c@gmail.com \
--to=leobras.c@gmail.com \
--cc=alexios.zavras@intel.com \
--cc=allison@lohutok.net \
--cc=benh@kernel.crashing.org \
--cc=christophe.leroy@c-s.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).