From: Breno Leitao <leitao@debian.org>
To: 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>, Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Shuah Khan <shuah@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>,
paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH net-next v3 1/5] netconsole: send the oops when oops_only is set
Date: Mon, 14 Sep 2026 05:09:51 -0700 [thread overview]
Message-ID: <20260914-netcons_ratelimit-v3-1-8e81b789ab37@debian.org> (raw)
In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org>
A target running with oops_only=1 receives nothing when the kernel
oopses, which is the one thing the option exists for. Only a panic
still gets through.
netconsole_write() bails out unless oops_in_progress is set, and that
flag is already gone by the time netconsole runs. netconsole is
CON_NBCON_ATOMIC_UNSAFE, so console_is_usable() keeps it out of the
emergency flush an oops prints in, and the records only leave the box
once the printer thread runs.
die() wakes that thread from oops_exit(), by which point
bust_spinlocks(0) has cleared oops_in_progress again. TAINT_DIE is set
in between, so test that as well, behind a helper.
With oops_only=1 on a netdevsim target, an lkdtm EXCEPTION produces 44
lines of oops. The receiver gets none of them before this change and
all of them after it, while ordinary messages stay suppressed.
The taint never clears, so from the first oops on, an oops_only target
sends everything instead of going quiet again. Sending the aftermath of
a crash beats sending nothing.
Fixes: 7eab73b18630 ("netconsole: convert to NBCON console infrastructure")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index b358e5c3673510..833da29717ed1d 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -83,7 +83,8 @@ MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<
static bool oops_only;
module_param(oops_only, bool, 0600);
-MODULE_PARM_DESC(oops_only, "Only log oops messages");
+MODULE_PARM_DESC(oops_only,
+ "Only log oops messages, everything once the kernel died");
#define NETCONSOLE_PARAM_TARGET_PREFIX "cmdline"
@@ -96,6 +97,17 @@ static int __init option_setup(char *opt)
__setup("netconsole=", option_setup);
#endif /* MODULE */
+/* The kernel is dying, or has died.
+ *
+ * oops_in_progress only spans the printing of the crash. netconsole is
+ * CON_NBCON_ATOMIC_UNSAFE, so the records reach the target later, from the
+ * printer thread, with the flag already cleared. TAINT_DIE outlives it.
+ */
+static bool netconsole_kernel_dying(void)
+{
+ return oops_in_progress || test_taint(TAINT_DIE);
+}
+
/* Linked list of all configured targets */
static LIST_HEAD(target_list);
/* target_cleanup_list is used to track targets that need to be cleaned outside
@@ -2474,7 +2486,7 @@ static void netconsole_write(struct nbcon_write_context *wctxt, bool extended)
{
struct netconsole_target *nt;
- if (oops_only && !oops_in_progress)
+ if (oops_only && !netconsole_kernel_dying())
return;
list_for_each_entry(nt, &target_list, list) {
--
2.53.0-Meta
next prev parent reply other threads:[~2026-09-14 12:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 12:09 [PATCH net-next v3 0/5] netconsole: Support messages ratelimit-ing Breno Leitao
2026-09-14 12:09 ` Breno Leitao [this message]
2026-09-23 15:38 ` [PATCH net-next v3 1/5] netconsole: send the oops when oops_only is set Gustavo Luiz Duarte
2026-09-14 12:09 ` [PATCH net-next v3 2/5] netconsole: add a per-target message rate limit Breno Leitao
2026-09-23 15:38 ` Gustavo Luiz Duarte
2026-09-14 12:09 ` [PATCH net-next v3 3/5] netconsole: allow configuring the rate limit interval through configfs Breno Leitao
2026-09-23 15:39 ` Gustavo Luiz Duarte
2026-09-14 12:09 ` [PATCH net-next v3 4/5] netconsole: allow configuring the rate limit burst " Breno Leitao
2026-09-23 15:39 ` Gustavo Luiz Duarte
2026-09-14 12:09 ` [PATCH net-next v3 5/5] docs: netconsole: document rate limit feature Breno Leitao
2026-09-23 15:40 ` Gustavo Luiz Duarte
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=20260914-netcons_ratelimit-v3-1-8e81b789ab37@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=asantostc@gmail.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavold@gmail.com \
--cc=horms@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=rdunlap@infradead.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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