summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2023-12-14 23:48:23 +0300
committerAndy Hu <andy.hu@starfivetech.com>2024-12-06 13:24:24 +0300
commit828f5c470f8cffe8d19df98b89a23a80fb916e53 (patch)
treed5461f3d85c408dbe8d94105802f629e07d6de4d
parentdf61638a5eada2ebb473687cb8d0b1aa01eb9550 (diff)
downloadlinux-828f5c470f8cffe8d19df98b89a23a80fb916e53.tar.xz
panic: Flush kernel log buffer at the end
If the kernel crashes in a context where printk() calls always defer printing (such as in NMI or inside a printk_safe section) then the final panic messages will be deferred to irq_work. But if irq_work is not available, the messages will not get printed unless explicitly flushed. The result is that the final "end Kernel panic" banner does not get printed. Add one final flush after the last printk() call to make sure the final panic messages make it out as well. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r--kernel/panic.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index ffa037fa777d..ef9f9a4e928d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -442,6 +442,14 @@ void panic(const char *fmt, ...)
/* Do not scroll important messages printed above */
suppress_printk = 1;
+
+ /*
+ * The final messages may not have been printed if in a context that
+ * defers printing (such as NMI) and irq_work is not available.
+ * Explicitly flush the kernel log buffer one last time.
+ */
+ console_flush_on_panic(CONSOLE_FLUSH_PENDING);
+
local_irq_enable();
for (i = 0; ; i += PANIC_TIMER_STEP) {
touch_softlockup_watchdog();