Re: [PATCH v2 3/3] printk: Use console_flush_one_record for legacy printer kthread

From: John Ogness
Date: Wed Oct 08 2025 - 12:15:48 EST


On 2025-10-03, Petr Mladek <pmladek@xxxxxxxx> wrote:
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 6c846d2d37d9..885506fa0178 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -3644,17 +3644,27 @@ static bool legacy_kthread_should_wakeup(void)
>
> static int legacy_kthread_func(void *unused)
> {
> - for (;;) {
> - wait_event_interruptible(legacy_wait, legacy_kthread_should_wakeup());
> + bool try_again;
> +
> +wait_for_event:
> + wait_event_interruptible(legacy_wait,
> + legacy_kthread_should_wakeup());

This should be on one line. Even with an 80-character limit it would
fit. ;-)

> +
> + do {
> + bool handover = false;
> + u64 next_seq;

Even though legacy_kthread_func() does not care, @next_seq should be
initialized to something since console_flush_one_record() reads this
value to decide if it should be increased. It really doesn't matter what
it is initialized to, but I guess 0 makes the most sense.

John