[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y3Nu+Bd/SWsYn8Sp@alley>
Date: Tue, 15 Nov 2022 11:50:32 +0100
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, Miguel Ojeda <ojeda@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Paul E . McKenney" <paulmck@...nel.org>
Subject: Re: [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
Powered by blists - more mailing lists