From: Sam Crossley <samuelcrossley@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>,
Breno Leitao <leitao@debian.org>, Petr Mladek <pmladek@suse.com>,
John Ogness <john.ogness@linutronix.de>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Paolo Abeni <pabeni@redhat.com>,
Randy Dunlap <rdunlap@infradead.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Simon Horman <horms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org,
Sam Crossley <samuelcrossley@gmail.com>
Subject: [PATCH RFC 2/2] netconsole: add configfs trigger to replay printk buffer
Date: Sat, 24 Oct 2026 16:06:04 -0700 [thread overview]
Message-ID: <20261024-netcons-replay-upstream-v1-2-9613f38496e5@gmail.com> (raw)
In-Reply-To: <20261024-netcons-replay-upstream-v1-0-9613f38496e5@gmail.com>
Netconsole only forwards records while an enabled target and its transport
are available, so enabling a target after startup, or recovering from an
outage, leaves a gap in the remote log.
Add a write-only replay attribute at /sys/kernel/config/netconsole.
Writing 1 rewinds the basic and extended netconsole consoles to the oldest
retained record and queues the records for transmission. Other registered
consoles are unaffected. Records keep their original printk timestamp and,
in extended format, their sequence number, so a receiver can deduplicate
what it already had.
Replay is best effort and asynchronous.
Note that "replay" is now an attribute in the netconsole configfs
directory, so it can no longer be used as a target name.
Signed-off-by: Sam Crossley <samuelcrossley@gmail.com>
---
Documentation/networking/netconsole.rst | 14 +++++++++++++-
drivers/net/netconsole.c | 25 +++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst
index 4ab5d7b05cf10..2e489dd64ba42 100644
--- a/Documentation/networking/netconsole.rst
+++ b/Documentation/networking/netconsole.rst
@@ -111,7 +111,8 @@ netconsole module (or kernel, if netconsole is built-in).
Some examples follow (where configfs is mounted at the /sys/kernel/config
mountpoint).
-To add a remote logging target (target names can be arbitrary)::
+To add a remote logging target (target names can be arbitrary, except
+"replay", which is used by the attribute below)::
cd /sys/kernel/config/netconsole/
mkdir target1
@@ -125,6 +126,17 @@ To remove a target::
rmdir /sys/kernel/config/netconsole/othertarget/
+To replay the records retained in the kernel printk ring buffer to the enabled
+netconsole targets::
+
+ echo 1 > /sys/kernel/config/netconsole/replay
+
+As during normal operation, records above the current console loglevel are not
+sent. The replay is best effort and asynchronous: the write returns once the
+consoles have been rewound, before the records have been transmitted, and a
+console whose lock cannot be acquired is skipped. Only netconsole output is
+replayed; other registered consoles are unaffected.
+
The interface exposes these parameters of a netconsole target to userspace:
=============== ================================= ============
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index b358e5c367351..f527a5ee45662 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1830,8 +1830,33 @@ static const struct configfs_group_operations netconsole_subsys_group_ops = {
.drop_item = drop_netconsole_target,
};
+static ssize_t replay_store(struct config_item *item, const char *buf,
+ size_t count)
+{
+ bool replay;
+ int ret;
+
+ ret = kstrtobool(buf, &replay);
+ if (ret)
+ return ret;
+ if (!replay)
+ return -EINVAL;
+
+ console_try_replay(&netconsole);
+ console_try_replay(&netconsole_ext);
+
+ return count;
+}
+CONFIGFS_ATTR_WO(, replay);
+
+static struct configfs_attribute *netconsole_subsys_attrs[] = {
+ &attr_replay,
+ NULL,
+};
+
static const struct config_item_type netconsole_subsys_type = {
.ct_group_ops = &netconsole_subsys_group_ops,
+ .ct_attrs = netconsole_subsys_attrs,
.ct_owner = THIS_MODULE,
};
--
2.53.0-Meta
next prev parent reply other threads:[~2026-10-24 23:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 23:06 [PATCH RFC 0/2] netconsole: allow replaying the printk buffer on demand Sam Crossley
2026-10-24 23:06 ` [PATCH RFC 1/2] printk: add per-console replay helper Sam Crossley
2026-10-24 23:06 ` Sam Crossley [this message]
2026-10-26 9:34 ` [PATCH RFC 0/2] netconsole: allow replaying the printk buffer on demand John Ogness
2026-10-26 11:44 ` Breno Leitao
2026-10-26 13:09 ` John Ogness
2026-10-26 14:58 ` Petr Mladek
2026-10-26 16:33 ` John Ogness
2026-10-26 17:49 ` Breno Leitao
2026-10-27 13:47 ` Petr Mladek
2026-10-27 12:58 ` Petr Mladek
2026-10-26 14:39 ` Chris Down
2026-10-26 15:32 ` 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=20261024-netcons-replay-upstream-v1-2-9613f38496e5@gmail.com \
--to=samuelcrossley@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmladek@suse.com \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.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
all inboxes | Powered by JetHome®