[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250819133149.7452-1-ryotkkr98@gmail.com>
Date: Tue, 19 Aug 2025 13:31:49 +0000
From: Ryo Takakura <ryotkkr98@...il.com>
To: cuiguoqi@...inos.cn
Cc: akpm@...ux-foundation.org,
bigeasy@...utronix.de,
catalin.marinas@....com,
clrkwllms@...nel.org,
farbere@...zon.com,
feng.tang@...ux.alibaba.com,
guoqi0226@....com,
joel.granados@...nel.org,
john.ogness@...utronix.de,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-rt-devel@...ts.linux.dev,
namcao@...utronix.de,
pmladek@...e.com,
rostedt@...dmis.org,
sravankumarlpu@...il.com,
takakura@...inux.co.jp,
tglx@...utronix.de,
will@...nel.org
Subject: Re: [PATCH] printk: Fix panic log flush to serial console during kdump in PREEMPT_RT kernels
Hi cuiguoqi!
I'm not an expert on the subject, but hope this helps.
On Thu, 7 Aug 2025 19:22:47 +0800, cuiguoqi wrote:
>When a system running a real-time (PREEMPT_RT) kernel panics and triggers kdump,
>the critical log messages (e.g., panic reason, stack traces) may fail to appear
>on the serial console.
>
>When kdump cannot be used properly, serial console logs are crucial,
>whether for diagnosing kdump issues or troubleshooting the underlying problem.
The console not being flushed in the case of kexec should be expected
as described [0]. Its about prioritizing kexec over serial output.
>This issue arises due to synchronization or deferred flushing of the printk buffer
>in real-time contexts, where preemptible console locks or delayed workqueues prevent
>timely log output before kexec transitions to the crash kernel.
>
> /**
> * kexec_image_info - For debugging output.
>@@ -176,6 +177,9 @@ void machine_kexec(struct kimage *kimage)
>
> pr_info("Bye!\n");
>
>+ if (IS_ENABLED(CONFIG_PREEMPT_RT) && in_kexec_crash)
>+ console_flush_on_panic(CONSOLE_FLUSH_PENDING);
>+
Calling console_flush_on_panic() while trying to kexec will
reduce its chance of success.
>diff --git a/kernel/panic.c b/kernel/panic.c
>index 72fcbb5..e0ad0df 100644
>--- a/kernel/panic.c
>+++ b/kernel/panic.c
>@@ -437,6 +437,8 @@ void vpanic(const char *fmt, va_list args)
> */
> kgdb_panic(buf);
>
>+ printk_legacy_allow_panic_sync();
>+
> /*
> * If we have crashed and we have a crash kernel loaded let it handle
> * everything else.
>@@ -450,8 +452,6 @@ void vpanic(const char *fmt, va_list args)
>
> panic_other_cpus_shutdown(_crash_kexec_post_notifiers);
>
>- printk_legacy_allow_panic_sync();
>-
The ordering here should be kept where we don't want CPUs other than
the one panicked flushing legacy consoles.
Sincerely,
Ryo Takakura
[0] https://lore.kernel.org/lkml/847cagmjsx.fsf@jogness.linutronix.de/
Powered by blists - more mailing lists