Re: [PATCH printk v3 05/19] printk: Fail pr_flush() if before SYSTEM_SCHEDULING

From: Petr Mladek
Date: Fri Jul 26 2024 - 09:15:13 EST


On Mon 2024-07-22 19:25:25, John Ogness wrote:
> A follow-up change adds pr_flush() to console unregistration.
> However, with boot consoles unregistration can happen very
> early if there are also regular consoles registering as well.
> In this case the pr_flush() is not important because the
> regular console manually flushes the boot consoles before
> unregistering them.

It is not much clear what the "manual flush" means. Is it
the console_flush_all() in get_init_console_seq()?

I would write something like:

<proposal>
In this case the pr_flush() is not important because all consoles
are flushed when checking the initial console sequence number.
</proposal>

> Allow pr_flush() to fail if @system_state has not yet reached
> SYSTEM_SCHEDULING. This avoids might_sleep() and msleep()
> explosions that would otherwise occur.

What do you mean with the explosion, please?
Does it add some warnings into the log?
Does it cause extra delays?

> Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
> ---
> kernel/printk/printk.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 641c2a8b0a09..39db56a32c5e 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -3946,6 +3946,10 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
> u64 diff;
> u64 seq;
>
> + /* Sorry, pr_flush() will not work this early. */
> + if (system_state < SYSTEM_SCHEDULING)
> + return false;
> +
> might_sleep();
>
> seq = prb_next_reserve_seq(prb);

The change seems acceptable. I just do not completely understand the
motivation.

Best Regards,
Petr