panic: Flush kernel log buffer at the end

JIRA: https://issues.redhat.com/browse/RHEL-3987
Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git/

commit db621f13961fb858c2545305b62a569ccf95314e
Author: John Ogness <john.ogness@linutronix.de>
Date:   Thu Dec 14 20:48:23 2023 +0000

    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>

Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
This commit is contained in:
Andrew Halaney 2024-04-18 13:15:58 -05:00 committed by Derek Barbosa
parent b546a30850
commit 5277972bb0
1 changed files with 8 additions and 0 deletions

View File

@ -445,6 +445,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();