[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWdXW6ohfQ7_z2B_@pathway.suse.cz>
Date: Wed, 14 Jan 2026 09:44:11 +0100
From: Petr Mladek <pmladek@...e.com>
To: Marcos Paulo de Souza <mpdesouza@...e.com>
Cc: Richard Weinberger <richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
Johannes Berg <johannes@...solutions.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <danielt@...nel.org>,
Douglas Anderson <dianders@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
John Ogness <john.ogness@...utronix.de>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Jiri Slaby <jirislaby@...nel.org>, Breno Leitao <leitao@...ian.org>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Kees Cook <kees@...nel.org>, Tony Luck <tony.luck@...el.com>,
"Guilherme G. Piccoli" <gpiccoli@...lia.com>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Andreas Larsson <andreas@...sler.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jacky Huang <ychuang3@...oton.com>,
Shan-Chun Hung <schung@...oton.com>,
Laurentiu Tudor <laurentiu.tudor@....com>,
linux-um@...ts.infradead.org, linux-kernel@...r.kernel.org,
kgdb-bugreport@...ts.sourceforge.net, linux-serial@...r.kernel.org,
netdev@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-hardening@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
sparclinux@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 03/19] printk: Drop flags argument from console_is_usable
On Sat 2025-12-27 09:16:10, Marcos Paulo de Souza wrote:
> The flags argument was also used to check if CON_NBCON was set, but their
> usage was fixed in the last commit. All current users are reading the
> variable just to call console_is_usable.
>
> By calling console_srcu_read_flags inside console_is_usable makes the
> code cleaner and removes one argument from the function.
>
> Along with it, create a variant called __console_is_usable that can be
> used under console_list_lock(), like unregister_console_locked.
>
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -656,13 +656,8 @@ extern bool nbcon_kdb_try_acquire(struct console *con,
> struct nbcon_write_context *wctxt);
> extern void nbcon_kdb_release(struct nbcon_write_context *wctxt);
>
> -/*
> - * Check if the given console is currently capable and allowed to print
> - * records. Note that this function does not consider the current context,
> - * which can also play a role in deciding if @con can be used to print
> - * records.
> - */
> -static inline bool console_is_usable(struct console *con, short flags,
> +/* Variant of console_is_usable() when the console_list_lock is held. */
Nit: The comment is a bit misleading because this function is called
also from console_is_usable() under console_srcu_read_lock().
I would say something like:
/*
* The caller must ensure that @con can't disappear either by taking
* console_list_lock() or console_srcu_read_lock(). See also
* console_is_usable().
*/
> +static inline bool __console_is_usable(struct console *con, short flags,
> enum nbcon_write_cb nwc)
> {
> if (!(flags & CON_ENABLED))
> @@ -707,6 +702,18 @@ static inline bool console_is_usable(struct console *con, short flags,
> return true;
> }
>
> +/*
> + * Check if the given console is currently capable and allowed to print
> + * records. Note that this function does not consider the current context,
> + * which can also play a role in deciding if @con can be used to print
> + * records.
And I would add here something like:
*
* Context: Must be called under console_srcu_read_lock().
> + */
> +static inline bool console_is_usable(struct console *con,
> + enum nbcon_write_cb nwc)
> +{
> + return __console_is_usable(con, console_srcu_read_flags(con), nwc);
> +}
> +
> #else
> static inline void nbcon_cpu_emergency_enter(void) { }
> static inline void nbcon_cpu_emergency_exit(void) { }
Otherwise, it looks good. It is a nice clean up.
Best Regards,
Petr
Powered by blists - more mailing lists