Re: [PATCH 2/2] printk: Make the console flush configurable in hotplug path
From: Petr Mladek
Date: Wed Sep 30 2020 - 09:57:23 EST
On Wed 2020-09-23 17:08:32, Prasad Sodagudi wrote:
> From: Mohammed Khajapasha <mkhaja@xxxxxxxxxxxxxx>
>
> The thread which initiates the hot plug can get scheduled
> out, while trying to acquire the console lock,
> thus increasing the hot plug latency. This option
> allows to selectively disable the console flush and
> in turn reduce the hot plug latency.
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 9b75f6b..f02d3ef 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2996,13 +3000,15 @@ static int __init printk_late_init(void)
> unregister_console(con);
> }
> }
> +#ifdef CONFIG_CONSOLE_FLUSH_ON_HOTPLUG
> ret = cpuhp_setup_state_nocalls(CPUHP_PRINTK_DEAD, "printk:dead", NULL,
> console_cpu_notify);
> WARN_ON(ret < 0);
> ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "printk:online",
> console_cpu_notify, NULL);
> WARN_ON(ret < 0);
> - return 0;
> +#endif
> + return ret;
Just a comment from the printk-side view. This change is wrong, definitely.
The above calls are needed with the current printk() design. They make
sure that someone would actually push the messages to the console.
Otherwise they might stay hidden seconds/minutes/hour/days until
another random printk() does the job.
They will not be needed with the ongoing printk rework[1] where
the consoles will get handled by a dedicated kthread.
[1] https://lore.kernel.org/lkml/87k1acz5rx.fsf@xxxxxxxxxxxxx/
Best Regards,
Petr