kernel/printk/printk_safe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Ryo Takakura <takakura@valinux.co.jp>
If PREEMPT_RT was enabled, printing for legacy consoles are deferred
by default, including after printk_legacy_allow_panic_sync() during
panic which allows direct printing afterwards in case of !PREEMPT_RT.
As a result, printing of messages during panic for PREEMPT_RT
is handled by the console_flush_on_panic() called at the end.
In case if kexec was loaded, console_flush_on_panic() will not be
called and starts booting into the second kernel without printing
the messages.
Allow direct printing for PREEMPT_RT during panic so that messages
before kexec gets printed.
Signed-off-by: Ryo Takakura <takakura@valinux.co.jp>
---
I was not sure if the behavior of deferred printing for PREEMPT_RT
during panic was expected or not. I think printing messages would be
useful even if kexec was loaded in case if it fails.
Thanks!
---
kernel/printk/printk_safe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 2b35a9d3919d..67a0510a8e12 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -44,7 +44,7 @@ bool is_printk_legacy_deferred(void)
* The per-CPU variable @printk_context can be read safely in any
* context. CPU migration is always disabled when set.
*/
- return (force_legacy_kthread() ||
+ return ((!this_cpu_in_panic() && force_legacy_kthread()) ||
this_cpu_read(printk_context) ||
in_nmi());
}
--
2.34.1
On 2024-10-10, takakura@valinux.co.jp wrote: > If PREEMPT_RT was enabled, printing for legacy consoles are deferred > by default, including after printk_legacy_allow_panic_sync() during > panic which allows direct printing afterwards in case of !PREEMPT_RT. > As a result, printing of messages during panic for PREEMPT_RT > is handled by the console_flush_on_panic() called at the end. This is on purpose because legacy consoles are not safe in many contexts under PREEMPT_RT. console_flush_on_panic() is used as a final "hope and pray" excercise even though it is not safe on PREEMPT_RT, which is why it is at the end of panic(). printk_legacy_allow_panic_sync() only exists for !PREEMPT_RT. > In case if kexec was loaded, console_flush_on_panic() will not be > called and starts booting into the second kernel without printing > the messages. If legacy printing is allowed before, the kexec may never happen because the unsafe legacy printers can hang the system. > Allow direct printing for PREEMPT_RT during panic so that messages > before kexec gets printed. Sorry, NACK. This goes against everything we have worked for with the rework. The solution is to update your console drivers to NBCON. John Ogness
Hi, John! On 2024-10-10, john.ogness@linutronix.de wrote: >On 2024-10-10, takakura@valinux.co.jp wrote: >> If PREEMPT_RT was enabled, printing for legacy consoles are deferred >> by default, including after printk_legacy_allow_panic_sync() during >> panic which allows direct printing afterwards in case of !PREEMPT_RT. >> As a result, printing of messages during panic for PREEMPT_RT >> is handled by the console_flush_on_panic() called at the end. > >This is on purpose because legacy consoles are not safe in many contexts >under PREEMPT_RT. console_flush_on_panic() is used as a final "hope and >pray" excercise even though it is not safe on PREEMPT_RT, which is why >it is at the end of panic(). printk_legacy_allow_panic_sync() only >exists for !PREEMPT_RT. > >> In case if kexec was loaded, console_flush_on_panic() will not be >> called and starts booting into the second kernel without printing >> the messages. > >If legacy printing is allowed before, the kexec may never happen because >the unsafe legacy printers can hang the system. Thanks for clarifying, I see that it was on purpose. >> Allow direct printing for PREEMPT_RT during panic so that messages >> before kexec gets printed. > >Sorry, NACK. This goes against everything we have worked for with the >rework. The solution is to update your console drivers to NBCON. Got it, I will look into it! >John Ogness Sincerely, Ryo Takakura
© 2016 - 2024 Red Hat, Inc.