Re: [PATCH v2 1/3] printk: Introduce console_flush_one_record

From: Andrew Murray

Date: Tue Sep 30 2025 - 09:21:16 EST


On Tue, 30 Sept 2025 at 13:54, 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 0efbcdda9aaba9d8d877df5e4f1db002d3a596bc..060d4919de320fe21fd7aca73ba497e27c4ff334 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -3161,6 +3161,100 @@ static inline void printk_kthreads_check_locked(void) { }
> >
> > #endif /* CONFIG_PRINTK */
> >
> > +
> > +/*
> > + * Print out one record for each console.
> > + *
> > + * @do_cond_resched is set by the caller. It can be true only in schedulable
> > + * context.
> > + *
> > + * @next_seq is set to the sequence number after the last available record.
> > + * The value is valid only when this function returns true.
> > + *
> > + * @handover will be set to true if a printk waiter has taken over the
> > + * console_lock, in which case the caller is no longer holding the
> > + * console_lock. Otherwise it is set to false.
> > + *
> > + * @any_usable will be set to true if there are any usable consoles.
> > + *
> > + * Returns true when there was at least one usable console and a record was
> > + * flushed. A returned false indicates there were no records to flush for any
> > + * of the consoles. It may also indicate that there were no usable consoles,
> > + * the context has been lost or there is a panic suitation. Regardless the
> > + * reason, the caller should assume it is not useful to immediately try again.
> > + *
> > + * Requires the console_lock.
> > + */
> > +static bool console_flush_one_record(bool do_cond_resched, u64 *next_seq, bool *handover,
> > + bool *any_usable)
> > +{
> > + struct console_flush_type ft;
> > + struct console *con;
> > + bool any_progress;
> > + int cookie;
> > +
> > + any_progress = false;
>
> I would let this be a definition initializer. And then place it sorted
> by length:
>
> struct console_flush_type ft;
> bool any_progress = false;
> struct console *con;
> int cookie;
>
> John

Sure, I'll update it on the next iteration.

Thanks,

Andrew Murray