From: Petr Mladek <pmladek@suse.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <danielt@kernel.org>,
Douglas Anderson <dianders@chromium.org>,
linux-kernel@vger.kernel.org,
kgdb-bugreport@lists.sourceforge.net
Subject: Re: [PATCH v4 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles
Date: Wed, 17 Sep 2025 15:18:17 +0200 [thread overview]
Message-ID: <aMq1GRHwo6xnsPBG@pathway.suse.cz> (raw)
In-Reply-To: <20250915-nbcon-kgdboc-v4-5-e2b6753bb566@suse.com>
On Mon 2025-09-15 08:20:34, Marcos Paulo de Souza wrote:
> Function kdb_msg_write was calling con->write for any found console,
> but it won't work on NBCON consoles. In this case we should acquire the
> ownership of the console using NBCON_PRIO_EMERGENCY, since printing
> kdb messages should only be interrupted by a panic.
>
> At this point, the console is required to use the atomic callback. The
> console is skipped if the write_atomic callback is not set or if the
> context could not be acquired. The validation of NBCON is done by the
> console_is_usable helper. The context is released right after
> write_atomic finishes.
>
> The oops_in_progress handling is only needed in the legacy consoles,
> so it was moved around the con->write callback.
>
> Suggested-by: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
It looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
See one note below.
> --- a/kernel/debug/kdb/kdb_io.c
> +++ b/kernel/debug/kdb/kdb_io.c
> @@ -589,24 +589,41 @@ static void kdb_msg_write(const char *msg, int msg_len)
> */
> cookie = console_srcu_read_lock();
> for_each_console_srcu(c) {
> - if (!(console_srcu_read_flags(c) & CON_ENABLED))
> + short flags = console_srcu_read_flags(c);
> +
> + if (!console_is_usable(c, flags, true))
> continue;
> if (c == dbg_io_ops->cons)
> continue;
> - if (!c->write)
> - continue;
> - /*
> - * Set oops_in_progress to encourage the console drivers to
> - * disregard their internal spin locks: in the current calling
> - * context the risk of deadlock is a bigger problem than risks
> - * due to re-entering the console driver. We operate directly on
> - * oops_in_progress rather than using bust_spinlocks() because
> - * the calls bust_spinlocks() makes on exit are not appropriate
> - * for this calling context.
> - */
> - ++oops_in_progress;
> - c->write(c, msg, msg_len);
> - --oops_in_progress;
> +
> + if (flags & CON_NBCON) {
> + struct nbcon_write_context wctxt = { };
> +
> + /*
> + * Do not continue if the console is NBCON and the context
> + * can't be acquired.
> + */
> + if (!nbcon_kdb_try_acquire(c, &wctxt))
> + continue;
> +
> + nbcon_write_context_set_buf(&wctxt, (char *)msg, msg_len);
I have overlooked the (char *) cast in the earlier versions of the
patchset. It would be nice to fix the nbcon API so that the parameter
could be passed as (const char *). It looks that the API using
struct nbcon_write_context never modifies the given buffer so
it would be the right thing.
But it is beyond the scope of this patchset. It would be material
for a separate code clean up ;-)
Best Regards,
Petr
prev parent reply other threads:[~2025-09-17 13:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 11:20 [PATCH v4 0/5] Handle NBCON consoles on KDB Marcos Paulo de Souza
2025-09-15 11:20 ` [PATCH v4 1/5] printk: nbcon: Export console_is_usable Marcos Paulo de Souza
2025-09-17 8:57 ` Petr Mladek
2025-09-17 12:21 ` Marcos Paulo de Souza
2025-09-17 14:07 ` Konstantin Ryabitsev
2025-09-18 13:02 ` Petr Mladek
2025-09-15 11:20 ` [PATCH v4 2/5] printk: nbcon: Introduce KDB helpers Marcos Paulo de Souza
2025-09-17 11:16 ` Petr Mladek
2025-09-15 11:20 ` [PATCH v4 3/5] printk: nbcon: Allow KDB to acquire the NBCON context Marcos Paulo de Souza
2025-09-17 12:09 ` Petr Mladek
2025-09-15 11:20 ` [PATCH v4 4/5] printk: nbcon: Export nbcon_write_context_set_buf Marcos Paulo de Souza
2025-09-17 12:18 ` Petr Mladek
2025-09-15 11:20 ` [PATCH v4 5/5] kdb: Adapt kdb_msg_write to work with NBCON consoles Marcos Paulo de Souza
2025-09-17 13:18 ` Petr Mladek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aMq1GRHwo6xnsPBG@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=danielt@kernel.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jason.wessel@windriver.com \
--cc=john.ogness@linutronix.de \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mpdesouza@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.