Thread (11 messages) 11 messages, 3 authors, 2026-01-23

Re: [PATCH net-next v2 3/5] netconsole: convert to NBCON console infrastructure

From: Simon Horman <horms@kernel.org>
Date: 2026-01-23 18:04:18
Also in: lkml

On Fri, Jan 23, 2026 at 02:48:47AM -0800, Breno Leitao wrote:
Hello Simon!

On Thu, Jan 22, 2026 at 09:09:34PM +0000, Simon Horman wrote:
quoted
On Tue, Jan 20, 2026 at 08:23:49AM -0800, Breno Leitao wrote:
quoted
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/ (local) [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
...
quoted
+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].
This is great. I hadn't realized that Al Viro's sparse tree includes this
additional check, which is really useful.

Are you using Al Viro's branch rather than the sparse mainline?

(I'm asking to see if I should also follow master and do the same, in
true padawan fashion)
Well, I think it would be best if mainline was fixed.
(Although I am yet to do anything towards making that happen.)

But to answer your question, yes, I am using Al's tree.
Since a few days ago when I tracked down that it allows
Sparse to once work significantly more robustly on the
current Kernel tree.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help