Skip to content

Commit d988d9a

Browse files
jognesspmladek
authored andcommitted
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 779dbc2 commit d988d9a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/panic.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ void panic(const char *fmt, ...)
446446

447447
/* Do not scroll important messages printed above */
448448
suppress_printk = 1;
449+
450+
/*
451+
* The final messages may not have been printed if in a context that
452+
* defers printing (such as NMI) and irq_work is not available.
453+
* Explicitly flush the kernel log buffer one last time.
454+
*/
455+
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
456+
449457
local_irq_enable();
450458
for (i = 0; ; i += PANIC_TIMER_STEP) {
451459
touch_softlockup_watchdog();

0 commit comments

Comments
 (0)