lkml.org 
[lkml]   [2022]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH printk v4 03/39] printk: Prepare for SRCU console list protection
On Mon 2022-11-14 17:34:56, John Ogness wrote:
> Provide an NMI-safe SRCU protected variant to walk the console list.
>
> Note that all console fields are now set before adding the console
> to the list to avoid the console becoming visible by SCRU readers
> before being fully initialized.
>
> This is a preparatory change for a new console infrastructure which
> operates independent of the console BKL.
>
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -3254,7 +3303,7 @@ int unregister_console(struct console *console)
> return -ENODEV;
> }
>
> - hlist_del_init(&console->node);
> + hlist_del_init_rcu(&console->node);

This should be hlist_del_rcu() here so that a list walker that it just
processing this console could see the rest of the list.

It seems that hlist_unhashed() checks only node.pprev pointer
so that we even do not need to initialize it.

We discussed this in v3 in the patch implementing
console_force_preferred_locked(), see
https://lore.kernel.org/r/Y20aBwNWT19YDeib@alley.
I forgot that unregister_console() might have the same problem.

Best Regards,
Petr

>
> /*
> * <HISTORICAL>
> @@ -3269,6 +3318,14 @@ int unregister_console(struct console *console)
> console_first()->flags |= CON_CONSDEV;
>
> console_unlock();
> +
> + /*
> + * Ensure that all SRCU list walks have completed. All contexts
> + * must not be able to see this console in the list so that any
> + * exit/cleanup routines can be performed safely.
> + */
> + synchronize_srcu(&console_srcu);
> +
> console_sysfs_notify();
>
> if (console->exit)
> --
> 2.30.2

\
 
 \ /
  Last update: 2022-11-15 11:54    [W:0.178 / U:1.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site