console_flush_all(): was: : was Re: [PATCH printk v2 10/12] printk: add kthread console printers

Petr Mladek
2022-04-07T16:56:39Z

On Tue 2022-04-05 15:31:33, John Ogness wrote:
> Create a kthread for each console to perform console printing. During
> normal operation (@system_state == SYSTEM_RUNNING), the kthread
> printers are responsible for all printing on their respective
> consoles.
>
> During non-normal operation, console printing is done as it has been:
> within the context of the printk caller or within irq work triggered
> by the printk caller.
>
> Console printers synchronize against each other and against console
> lockers by taking the console lock for each message that is printed.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
> include/linux/console.h | 2 +
> kernel/printk/printk.c | 262 ++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 252 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 8c1686e2c233..9a251e70c090 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -2773,6 +2809,10 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
> *handover = false;
>
> do {
> + /* Let the kthread printers do the work if they can. */
> + if (!allow_direct_printing())
> + break;

We should return either "true" or "false" here to have predictable
result.

I suggest to return "false". I would mean that the function did not
finish the job as I suggested for the 6th patch.

> +
> any_progress = false;
>
> for_each_console(con) {

Best Regards,
Petr