[PATCH net-next v6 0/4] net: netconsole: convert to NBCON console infrastructure

Breno Leitao posted 4 patches 3 days, 22 hours ago
There is a newer version of this series
drivers/net/Kconfig               |   1 +
drivers/net/netconsole.c          | 153 +++++++++++++++++++++++---------------
include/linux/console.h           |   8 ++
kernel/printk/internal.h          |   8 ++
kernel/printk/nbcon.c             |  16 ++++
kernel/printk/printk.c            |  54 +++++++++++++-
kernel/printk/printk_ringbuffer.h |   5 ++
lib/Kconfig.debug                 |  20 +++++
8 files changed, 205 insertions(+), 60 deletions(-)
[PATCH net-next v6 0/4] net: netconsole: convert to NBCON console infrastructure
Posted by Breno Leitao 3 days, 22 hours ago
This series adds support for the nbcon (new buffer console) infrastructure
to netconsole, enabling lock-free, priority-based console operations that
are safer in crash scenarios.

The implementation is introduced in three steps:

0) Extend printk to expose CPU and taskname (task->comm) where the
   printk originated from. (Thanks John and Petr for the support in
   getting this done)
1) Refactor the message fragmentation logic into a reusable helper function
2) Extend nbcon support to non-extended (basic) consoles using the same
   infrastructure.

The initial discussion about it appeared a while ago in [1], in order to
solve Mike's HARDIRQ-safe -> HARDIRQ-unsafe lock order warning, and the root
cause is that some hosts were calling IRQ unsafe locks from inside console
lock.

At that time, we didn't have the CON_NBCON_ATOMIC_UNSAFE yet. John
kindly implemented CON_NBCON_ATOMIC_UNSAFE in 187de7c212e5 ("printk:
nbcon: Allow unsafe write_atomic() for panic"), and now we can
implement netconsole on top of nbcon.

Important to note that netconsole continues to call netpoll and the
network TX helpers with interrupt disable, given the TX are called with
target_list_lock.

Netdev maintainers, Petr suggested that this patchset goes through netdev[2]

Link: https://lore.kernel.org/all/b2qps3uywhmjaym4mht2wpxul4yqtuuayeoq4iv4k3zf5wdgh3@tocu6c7mj4lt/ [1]
Link: https://lore.kernel.org/all/aW9D5M0o9_8hdVvt@pathway.suse.cz/ [2]

Signed-off-by: Breno Leitao <leitao@debian.org>

---
Changes in v6:
- Do not select PRINTK_EXECUTION_CTX in NETCONSOLE_DYNAMIC (Jakub)
- Do not make PRINTK_EXECUTION_CTX user visible (Jakub)
- Link to v5: https://patch.msgid.link/20260128-nbcon-v5-0-93b4ddbc181a@debian.org

Changes in v5:
- Replace the memcpy size from TASK_COMM_LEN to sizeof(wctxt->comm)
  (John)
- Add some compilation time asserts (John)
- Change the implementation of printk_info_get_cpu()
- Link to v4: https://patch.msgid.link/20260123-nbcon-v4-0-46a5cf567926@debian.org

Changes in v4:
- Added __acquires/__releases compiler annotations (Simon)
- Rebased on top of net-next, which included changes from Andre
- Netconsole Dynamic now selects PRINTK_EXECUTION_CTX and
  CONSOLE_HAS_EXECUTION_CTX
- Link to v3: https://patch.msgid.link/20260122-nbcon-v3-0-a722f2f0dfa5@debian.org

Changes in v3:
- Fixed netconsole selection (s/CONSOLE_HAS_EXECUTION_CTX/PRINTK_EXECUTION_CTX)
- Removed unnecessary "inline" in C file.
- Tried to shrink the get the lines to fit 80-columns
- Link to v2: https://patch.msgid.link/20260120-nbcon-v2-0-b61f960587a8@debian.org

Changes in v2:
- Return if not able to nbcon_enter_unsafe() instead of retrying on
  a different target (Marcos)
- Add printk that supports context information, which will be used later
  by netconsole sysdata. (John, Petr)
- An extra patch to bring symmetry to send_msg_udp()
- Link to v1: https://patch.msgid.link/20251222-nbcon-v1-0-65b43c098708@debian.org

Changes in V1 from RFC:
  * Removed the extra CONFIG for NBCON, given we don't want to support
    both console. Move to nbcon as the only console framework supported
  * Incorporated the changes from Petr.
  * Some renames to make the code more consistent.
  * RFC Link: https://lore.kernel.org/all/20251121-nbcon-v1-0-503d17b2b4af@debian.org/

---
Breno Leitao (4):
      printk: Add execution context (task name/CPU) to printk_info
      netconsole: extract message fragmentation into send_msg_udp()
      netconsole: convert to NBCON console infrastructure
      netconsole: Use printk context for CPU and task information

 drivers/net/Kconfig               |   1 +
 drivers/net/netconsole.c          | 153 +++++++++++++++++++++++---------------
 include/linux/console.h           |   8 ++
 kernel/printk/internal.h          |   8 ++
 kernel/printk/nbcon.c             |  16 ++++
 kernel/printk/printk.c            |  54 +++++++++++++-
 kernel/printk/printk_ringbuffer.h |   5 ++
 lib/Kconfig.debug                 |  20 +++++
 8 files changed, 205 insertions(+), 60 deletions(-)
---
base-commit: bf2e36c9dab95e41516fbcf7b1cc804539b2d021
change-id: 20251117-nbcon-f24477ca9f3e

Best regards,
--  
Breno Leitao <leitao@debian.org>
Re: [PATCH net-next v6 0/4] net: netconsole: convert to NBCON console infrastructure
Posted by John Ogness 2 days, 16 hours ago
On 2026-02-03, Breno Leitao <leitao@debian.org> wrote:
> This series adds support for the nbcon (new buffer console) infrastructure
> to netconsole, enabling lock-free, priority-based console operations that
> are safer in crash scenarios.
>
> The implementation is introduced in three steps:
>
> 0) Extend printk to expose CPU and taskname (task->comm) where the
>    printk originated from. (Thanks John and Petr for the support in
>    getting this done)
> 1) Refactor the message fragmentation logic into a reusable helper function
> 2) Extend nbcon support to non-extended (basic) consoles using the same
>    infrastructure.
>
> The initial discussion about it appeared a while ago in [1], in order to
> solve Mike's HARDIRQ-safe -> HARDIRQ-unsafe lock order warning, and the root
> cause is that some hosts were calling IRQ unsafe locks from inside console
> lock.
>
> At that time, we didn't have the CON_NBCON_ATOMIC_UNSAFE yet. John
> kindly implemented CON_NBCON_ATOMIC_UNSAFE in 187de7c212e5 ("printk:
> nbcon: Allow unsafe write_atomic() for panic"), and now we can
> implement netconsole on top of nbcon.
>
> Important to note that netconsole continues to call netpoll and the
> network TX helpers with interrupt disable, given the TX are called with
> target_list_lock.
>
> Netdev maintainers, Petr suggested that this patchset goes through netdev[2]
>
> Link: https://lore.kernel.org/all/b2qps3uywhmjaym4mht2wpxul4yqtuuayeoq4iv4k3zf5wdgh3@tocu6c7mj4lt/ [1]
> Link: https://lore.kernel.org/all/aW9D5M0o9_8hdVvt@pathway.suse.cz/ [2]
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
>
> ---
> Changes in v6:
> - Do not select PRINTK_EXECUTION_CTX in NETCONSOLE_DYNAMIC (Jakub)
> - Do not make PRINTK_EXECUTION_CTX user visible (Jakub)

I am really sorry, but I failed to communicate what I meant about
introducing the CONSOLE_HAS_EXECUTION_CTX symbol.

As Jakub mentioned, NETCONSOLE_DYNAMIC should just directly select
PRINTK_EXECUTION_CTX and get rid of the CONSOLE_HAS_EXECUTION_CTX symbol
(like you had in v1).

I apologize for the confusion and wasted effort here.

John
Re: [PATCH net-next v6 0/4] net: netconsole: convert to NBCON console infrastructure
Posted by Breno Leitao 1 day, 3 hours ago
On Thu, Feb 05, 2026 at 12:12:52AM +0106, John Ogness wrote:
> On 2026-02-03, Breno Leitao <leitao@debian.org> wrote:
> > This series adds support for the nbcon (new buffer console) infrastructure
> > to netconsole, enabling lock-free, priority-based console operations that
> > are safer in crash scenarios.
> >
> > The implementation is introduced in three steps:
> >
> > 0) Extend printk to expose CPU and taskname (task->comm) where the
> >    printk originated from. (Thanks John and Petr for the support in
> >    getting this done)
> > 1) Refactor the message fragmentation logic into a reusable helper function
> > 2) Extend nbcon support to non-extended (basic) consoles using the same
> >    infrastructure.
> >
> > The initial discussion about it appeared a while ago in [1], in order to
> > solve Mike's HARDIRQ-safe -> HARDIRQ-unsafe lock order warning, and the root
> > cause is that some hosts were calling IRQ unsafe locks from inside console
> > lock.
> >
> > At that time, we didn't have the CON_NBCON_ATOMIC_UNSAFE yet. John
> > kindly implemented CON_NBCON_ATOMIC_UNSAFE in 187de7c212e5 ("printk:
> > nbcon: Allow unsafe write_atomic() for panic"), and now we can
> > implement netconsole on top of nbcon.
> >
> > Important to note that netconsole continues to call netpoll and the
> > network TX helpers with interrupt disable, given the TX are called with
> > target_list_lock.
> >
> > Netdev maintainers, Petr suggested that this patchset goes through netdev[2]
> >
> > Link: https://lore.kernel.org/all/b2qps3uywhmjaym4mht2wpxul4yqtuuayeoq4iv4k3zf5wdgh3@tocu6c7mj4lt/ [1]
> > Link: https://lore.kernel.org/all/aW9D5M0o9_8hdVvt@pathway.suse.cz/ [2]
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> >
> > ---
> > Changes in v6:
> > - Do not select PRINTK_EXECUTION_CTX in NETCONSOLE_DYNAMIC (Jakub)
> > - Do not make PRINTK_EXECUTION_CTX user visible (Jakub)
> 
> I am really sorry, but I failed to communicate what I meant about
> introducing the CONSOLE_HAS_EXECUTION_CTX symbol.
> 
> As Jakub mentioned, NETCONSOLE_DYNAMIC should just directly select
> PRINTK_EXECUTION_CTX and get rid of the CONSOLE_HAS_EXECUTION_CTX symbol
> (like you had in v1).

Ack! Let me update it.

Thanks for the clarification,
--breno