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

From: Andrew Murray

Date: Tue Sep 30 2025 - 09:20:44 EST


On Tue, 30 Sept 2025 at 14:03, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
>
> On 2025-09-27, Andrew Murray <amurray@xxxxxxxxxxxxxxxxxxxx> wrote:
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index e2c1cacdb4164489c60fe38f1e2837eb838107d6..2c9b9383df76de956a05211537264fd6e06366da 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -3668,17 +3668,29 @@ 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 any_progress;
> > +
> > +wait_for_event:
> > + wait_event_interruptible(legacy_wait,
> > + legacy_kthread_should_wakeup());
> > +
> > + do {
> > + bool any_usable;
> > + bool handover = false;
> > + u64 next_seq;
>
> Please sort by length. It looks nicer. ;-)
>
> bool handover = false;
> bool any_usable;
> u64 next_seq;

I agree :)


>
> Note that it is fine that @any_usable is not initialized here because
> legacy_kthread_func() does not actually care about this variable.

Yes, that's correct. I wasn't sure whether to set it to something
which would likely get optimised away, or if there was some way I
could mark it as not used (didn't see anything beneficial).

Thanks,

Andrew Murray

>
> John