]> Git Repo - linux.git/commitdiff
panic: Flush kernel log buffer at the end
authorJohn Ogness <[email protected]>
Wed, 7 Feb 2024 13:41:02 +0000 (14:47 +0106)
committerPetr Mladek <[email protected]>
Wed, 7 Feb 2024 16:23:19 +0000 (17:23 +0100)
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 <[email protected]>
Reviewed-by: Petr Mladek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Petr Mladek <[email protected]>
kernel/panic.c

index 2807639aab51d1f631fa834dd2c7e1472864b25f..f22d8f33ea14752819044715e1dfa3234fc36198 100644 (file)
@@ -446,6 +446,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();
This page took 0.055824 seconds and 4 git commands to generate.