[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmryjZaYbwUcVrut@pathway.suse.cz>
Date: Thu, 13 Jun 2024 15:22:21 +0200
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
Subject: Re: [PATCH printk v2 06/18] printk: nbcon: Add context to
console_is_usable()
On Tue 2024-06-04 01:30:41, John Ogness wrote:
> The nbcon consoles have two callbacks to be used for different
> contexts. In order to determine if an nbcon console is usable,
> console_is_usable() needs to know if it is a context that will
> use the write_atomic() callback or the write_thread() callback.
>
> Add an extra parameter @use_atomic to specify this.
>
> Signed-off-by: John Ogness <john.ogness@...utronix.de>
> ---
> kernel/printk/internal.h | 16 ++++++++++------
> kernel/printk/nbcon.c | 8 ++++----
> kernel/printk/printk.c | 6 ++++--
> 3 files changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
> index 38680c6b2b39..243d3d3bc889 100644
> --- a/kernel/printk/internal.h
> +++ b/kernel/printk/internal.h
> @@ -100,7 +100,7 @@ void nbcon_kthread_create(struct console *con);
> * 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)
> +static inline bool console_is_usable(struct console *con, short flags, bool use_atomic)
> {
> if (!(flags & CON_ENABLED))
> return false;
> @@ -109,10 +109,13 @@ static inline bool console_is_usable(struct console *con, short flags)
> return false;
>
> if (flags & CON_NBCON) {
> - if (!con->write_atomic)
> - return false;
> - if (!con->write_thread)
> - return false;
> + if (use_atomic) {
> + if (!con->write_atomic)
> + return false;
> + } else {
> + if (!con->write_thread)
> + return false;
> + }
> } else {
> if (!con->write)
> return false;
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -4018,8 +4018,10 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
> * that they make forward progress, so only increment
> * @diff for usable consoles.
> */
> - if (!console_is_usable(c, flags))
> + if (!console_is_usable(c, flags, true) &&
> + !console_is_usable(c, flags, false)) {
> continue;
> + }
>
> if (flags & CON_NBCON) {
> printk_seq = nbcon_seq_read(c);
I wonder if it is worth it. Do we seriously want to support nbcon
without con->write_kthread() or con->write_atomic() callbacks?
For example, I see in kernel/printk/printk.c:
void register_console(struct console *newcon)
{
bool use_device_lock = (newcon->flags & CON_NBCON) && newcon->write_atomic;
We would need to extend this check if we wanted to allow nbcon
consoles without con->nbcon_atomic()...
Best Regards,
Petr
Powered by blists - more mailing lists