public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	pmladek@suse.com, john.ogness@linutronix.de,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	asantostc@gmail.com, efault@gmx.de, gustavold@gmail.com,
	calvin@wbinvd.org, jv@jvosburgh.net, mpdesouza@suse.com,
	kernel-team@meta.com
Subject: Re: [PATCH net-next v2 3/5] netconsole: convert to NBCON console infrastructure
Date: Thu, 22 Jan 2026 21:09:34 +0000	[thread overview]
Message-ID: <aXKSDoi8Yue_Ghxj@horms.kernel.org> (raw)
In-Reply-To: <20260120-nbcon-v2-3-b61f960587a8@debian.org>

On Tue, Jan 20, 2026 at 08:23:49AM -0800, Breno Leitao wrote:
> Convert netconsole from the legacy console API to the NBCON framework.
> NBCON provides threaded printing which unblocks printk()s and flushes in
> a thread, decoupling network TX from printk() when netconsole is
> in use.
> 
> Since netconsole relies on the network stack which cannot safely operate
> from all atomic contexts, mark both consoles with
> CON_NBCON_ATOMIC_UNSAFE. (See discussion in [1])
> 
> CON_NBCON_ATOMIC_UNSAFE restricts write_atomic() usage to emergency
> scenarios (panic) where regular messages are sent in threaded mode.
> 
> Implementation changes:
> - Unify write_ext_msg() and write_msg() into netconsole_write()
> - Add device_lock/device_unlock callbacks to manage target_list_lock
> - Use nbcon_enter_unsafe()/nbcon_exit_unsafe() around network
>   operations.
>   - If nbcon_enter_unsafe() fails, just return given netconsole lost
>     the ownership of the console.
> - Set write_thread and write_atomic callbacks (both use same function)
> 
> Link: https://lore.kernel.org/all/b2qps3uywhmjaym4mht2wpxul4yqtuuayeoq4iv4k3zf5wdgh3@tocu6c7mj4lt/ [1]
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  drivers/net/netconsole.c | 97 ++++++++++++++++++++++++++++++------------------
>  1 file changed, 60 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c

...

> +static void netconsole_device_lock(struct console *con __always_unused,
> +				   unsigned long *flags)
> +{
> +	spin_lock_irqsave(&target_list_lock, *flags);
> +}
> +
> +static void netconsole_device_unlock(struct console *con __always_unused,
> +				     unsigned long flags)
> +{
>  	spin_unlock_irqrestore(&target_list_lock, flags);
>  }
>  

Hi Breno,

I'm wondering if we could consider the following annotations,
as "suggested" by Sparse[1].

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index c5d7e97fe2a7..79e39a6c5343 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1772,12 +1772,14 @@ static void netconsole_write_basic(struct console *con __always_unused,
 
 static void netconsole_device_lock(struct console *con __always_unused,
 				   unsigned long *flags)
+__acquires(&target_list_lock)
 {
 	spin_lock_irqsave(&target_list_lock, *flags);
 }
 
 static void netconsole_device_unlock(struct console *con __always_unused,
 				     unsigned long flags)
+__releases(&target_list_lock)
 {
 	spin_unlock_irqrestore(&target_list_lock, flags);
 }

[1] This particular commit of Sparse, from Al Viro's tree:
    https://git.kernel.org/pub/scm/linux/kernel/git/viro/sparse.git/commit/?id=2634e39bf02697a18fece057208150362c985992
    Which addresses this mess:
    https://lore.kernel.org/all/bf5b9a62-a120-421e-908d-1404c42e0b60@kernel.org/

  reply	other threads:[~2026-01-22 21:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 16:23 [PATCH net-next v2 0/5] net: netconsole: convert to NBCON console infrastructure Breno Leitao
2026-01-20 16:23 ` [PATCH net-next v2 1/5] printk: Add execution context (task name/CPU) to printk_info Breno Leitao
2026-01-21 11:41   ` Breno Leitao
2026-01-20 16:23 ` [PATCH net-next v2 2/5] netconsole: extract message fragmentation into send_msg_udp() Breno Leitao
2026-01-20 16:23 ` [PATCH net-next v2 3/5] netconsole: convert to NBCON console infrastructure Breno Leitao
2026-01-22 21:09   ` Simon Horman [this message]
2026-01-23 10:48     ` Breno Leitao
2026-01-23 18:04       ` Simon Horman
2026-01-20 16:23 ` [PATCH net-next v2 4/5] netconsole: Use printk context for CPU and task information Breno Leitao
2026-01-21  5:40   ` kernel test robot
2026-01-20 16:23 ` [PATCH net-next v2 5/5] netconsole: pass wctxt to send_msg_udp() for consistency Breno Leitao

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=aXKSDoi8Yue_Ghxj@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=asantostc@gmail.com \
    --cc=calvin@wbinvd.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=efault@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavold@gmail.com \
    --cc=john.ogness@linutronix.de \
    --cc=jv@jvosburgh.net \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pmladek@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox