Re: [PATCH printk v1 13/13] console: introduce CON_MIGHT_SLEEP for vt

From: Petr Mladek
Date: Wed Feb 23 2022 - 08:38:06 EST


On Mon 2022-02-07 20:49:23, John Ogness wrote:
> Deadlocks and the framebuffer console have been a recurring issue
> that is getting worse. Daniel Vetter suggested [0] that
> fbcon->write() should no longer be called from an atomic context.

We should make it clear that people will not longer see kernel
messages on ttyX during early boot, panic, and in some other
situations when printk kthreads are not available.

Or do I miss something?

Do we really want this?

Do the tty maintainers really want to give up on supporting
modes when processes/kthreads do not work?

Maybe, it is inevitable. Maybe, people are not using tty
for debugging too much.

Anyway, this change has to be approved by tty guys.

Best Regards,
Petr

> Introduce a new console flag CON_MIGHT_SLEEP for a console driver to
> specify that it is only called from sleepable contexts. Set the
> fbcon to use this new flag.
>
> [0] https://lore.kernel.org/all/YYuS1uNhxWOEX1Ci@phenom.ffwll.local
>
> Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
> ---
> drivers/tty/vt/vt.c | 2 +-
> include/linux/console.h | 1 +
> kernel/printk/printk.c | 2 ++
> 3 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 7359c3e80d63..ab4712cc9327 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -3161,7 +3161,7 @@ static struct console vt_console_driver = {
> .write = vt_console_print,
> .device = vt_console_device,
> .unblank = unblank_screen,
> - .flags = CON_PRINTBUFFER,
> + .flags = CON_PRINTBUFFER|CON_MIGHT_SLEEP,
> .index = -1,
> };
> #endif
> diff --git a/include/linux/console.h b/include/linux/console.h
> index c51c7f5507a5..ea52c56b3ff8 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -138,6 +138,7 @@ static inline int con_debug_leave(void)
> #define CON_BRL (32) /* Used for a braille device */
> #define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */
> #define CON_PAUSED (128) /* Sleep while console is locked */
> +#define CON_MIGHT_SLEEP (256) /* Can only be called from sleepable context */
>
> struct console {
> char name[16];
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 086155578f10..b92ef67a5aa2 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2836,6 +2836,8 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
>
> if (!console_is_usable(con))
> continue;
> + if ((con->flags & CON_MIGHT_SLEEP) && !do_cond_resched)
> + continue;

This means that ttyX will be able to show the messages only
from a process context. It it will not longer show the messages
during, early boot, panic, suspend, and some other situations.

Do we really want this?

Do the tty maintainers really want to give up support
in these modes when processes/kthreads do not work?

Maybe, it is inevitable. Maybe, people are not using tty
for debugging too much.

Anyway, this has to be





> any_usable = true;
>
> if (con->flags & CON_EXTENDED) {
> --
> 2.30.2