Messages in this thread | | | Date | Fri, 11 Feb 2022 17:05:58 +0100 | From | Petr Mladek <> | Subject | Re: [PATCH printk v1 03/13] printk: use percpu flag instead of cpu_online() |
| |
On Mon 2022-02-07 20:49:13, John Ogness wrote: > The CON_ANYTIME console flag is used to label consoles that will > work correctly before percpu resources are allocated. To check > the condition, cpu_online(raw_smp_processor_id()) was used. > However, this is odd because CPUs can go offline at a later point. > Also, the function is forced to use the raw_ variant because > migration is not disabled. > > Since commit ab6f762f0f53 ("printk: queue wake_up_klogd irq_work > only if per-CPU areas are ready") there is a variable to identify > if percpu resources have been allocated. Use that variable instead > of cpu_online(raw_smp_processor_id()). > > Signed-off-by: John Ogness <john.ogness@linutronix.de>
I dug more into the history to be more confident about the change. I am not sure that it is safe.
CON_ANYTIME really seems to be related to per-CPU variables and early boot, see the commit 76a8ad293912cd2f01eca ("[PATCH] Make printk work for really early debugging").
I am not 100% sure. I think that the support for per-CPU variables is enabled by setup_per_cpu_areas(). It is done for_each_possible_cpu() So that per-CPU variables should always be available after printk_percpu_data_ready(). So far, so good.
The problem is the commit ac25575203c11145066ea ("[PATCH] CPU hotplug printk fix"). It suggests that per-CPU data of slab are freed during hotplug.
There are many other things that are manipulated during cpu hotplug. And there are the two notifiers "printk:dead" and "printk:online", see printk_late_init(). Maybe, we should use them to decide whether the non-trivial consoles are callable during CPU hotplug.
Best Regards, Petr
| |