* [PATCH] printk: Allow direct printing for PREEMPT_RT during panic
@ 2024-10-10 3:55 takakura
2024-10-10 8:41 ` John Ogness
0 siblings, 1 reply; 3+ messages in thread
From: takakura @ 2024-10-10 3:55 UTC (permalink / raw)
To: pmladek, rostedt, john.ogness, senozhatsky; +Cc: linux-kernel, Ryo Takakura
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] printk: Allow direct printing for PREEMPT_RT during panic
2024-10-10 3:55 [PATCH] printk: Allow direct printing for PREEMPT_RT during panic takakura
@ 2024-10-10 8:41 ` John Ogness
2024-10-10 9:47 ` takakura
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2024-10-10 8:41 UTC (permalink / raw)
To: takakura, pmladek, rostedt, senozhatsky; +Cc: linux-kernel, Ryo Takakura
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] printk: Allow direct printing for PREEMPT_RT during panic
2024-10-10 8:41 ` John Ogness
@ 2024-10-10 9:47 ` takakura
0 siblings, 0 replies; 3+ messages in thread
From: takakura @ 2024-10-10 9:47 UTC (permalink / raw)
To: john.ogness; +Cc: linux-kernel, pmladek, rostedt, senozhatsky, takakura
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-10 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 3:55 [PATCH] printk: Allow direct printing for PREEMPT_RT during panic takakura
2024-10-10 8:41 ` John Ogness
2024-10-10 9:47 ` takakura
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome