From: Jon Hunter <jonathanh@nvidia.com>
To: Kartik Rajput <kkartik@nvidia.com>, Kees Cook <kees@kernel.org>,
Tony Luck <tony.luck@intel.com>,
"Guilherme G . Piccoli" <gpiccoli@igalia.com>,
Thierry Reding <thierry.reding@kernel.org>,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v2] pstore/zone: Emit registration message as a single pr_info()
Date: Tue, 12 May 2026 14:50:36 +0100 [thread overview]
Message-ID: <d19aadfa-6b41-40ac-b3c7-b121f3a8bc59@nvidia.com> (raw)
In-Reply-To: <20260426090929.1528232-1-kkartik@nvidia.com>
On 26/04/2026 10:09, Kartik Rajput wrote:
> register_pstore_zone() prints its "registered ... as backend for ..."
> summary as a pr_info() followed by several pr_cont() calls.
>
> pr_cont() is not atomic and has no log level of its own. It appends
> to whichever line was most recently opened by a printk(). If a
> pr_err() or pr_warn() from another CPU or an interrupt handler
> preempts the pr_info() / pr_cont() sequence, it closes the
> continuation between the fragments. This can cause parts of the
> pstore registration message to appear at the wrong log level and be
> interleaved with other messages.
>
> Furthermore, this causes the detection of new warning and error
> messages in the kernel log to be unreliable.
>
> Format the registration line into a seq_buf and emit it with a
> single pr_info() call, making the line atomic with respect to
> concurrent printk() callers. No functional change to registration.
>
> Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
> ---
> Changes in v2:
> - Use a seq_buf to build the registration line instead of scnprintf()
> calls.
> - Link to v1: https://lore.kernel.org/all/20260424095820.1433700-1-kkartik@nvidia.com/
> ---
> fs/pstore/zone.c | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c
> index a3b003f9a3a0..004a5d5f376b 100644
> --- a/fs/pstore/zone.c
> +++ b/fs/pstore/zone.c
> @@ -12,6 +12,7 @@
> #include <linux/slab.h>
> #include <linux/mount.h>
> #include <linux/printk.h>
> +#include <linux/seq_buf.h>
> #include <linux/fs.h>
> #include <linux/pstore_zone.h>
> #include <linux/kdev_t.h>
> @@ -1301,6 +1302,10 @@ int register_pstore_zone(struct pstore_zone_info *info)
> {
> int err = -EINVAL;
> struct psz_context *cxt = &pstore_zone_cxt;
> + char buf[256];
> + struct seq_buf s;
> +
> + seq_buf_init(&s, buf, sizeof(buf));
>
> if (info->total_size < 4096) {
> pr_warn("total_size must be >= 4096\n");
> @@ -1383,30 +1388,28 @@ int register_pstore_zone(struct pstore_zone_info *info)
> }
> cxt->pstore.data = cxt;
>
> - pr_info("registered %s as backend for", info->name);
> cxt->pstore.max_reason = info->max_reason;
> cxt->pstore.name = info->name;
> if (info->kmsg_size) {
> cxt->pstore.flags |= PSTORE_FLAGS_DMESG;
> - pr_cont(" kmsg(%s",
> - kmsg_dump_reason_str(cxt->pstore.max_reason));
> - if (cxt->pstore_zone_info->panic_write)
> - pr_cont(",panic_write");
> - pr_cont(")");
> + seq_buf_printf(&s, " kmsg(%s%s)",
> + kmsg_dump_reason_str(cxt->pstore.max_reason),
> + cxt->pstore_zone_info->panic_write ? ",panic_write" : "");
> }
> if (info->pmsg_size) {
> cxt->pstore.flags |= PSTORE_FLAGS_PMSG;
> - pr_cont(" pmsg");
> + seq_buf_puts(&s, " pmsg");
> }
> if (info->console_size) {
> cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE;
> - pr_cont(" console");
> + seq_buf_puts(&s, " console");
> }
> if (info->ftrace_size) {
> cxt->pstore.flags |= PSTORE_FLAGS_FTRACE;
> - pr_cont(" ftrace");
> + seq_buf_puts(&s, " ftrace");
> }
> - pr_cont("\n");
> +
> + pr_info("registered %s as backend for%s\n", info->name, seq_buf_str(&s));
>
> err = pstore_register(&cxt->pstore);
> if (err) {
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Jon
--
nvpublic
prev parent reply other threads:[~2026-05-12 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-26 9:09 [PATCH v2] pstore/zone: Emit registration message as a single pr_info() Kartik Rajput
2026-05-12 13:50 ` Jon Hunter [this message]
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=d19aadfa-6b41-40ac-b3c7-b121f3a8bc59@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=gpiccoli@igalia.com \
--cc=kees@kernel.org \
--cc=kkartik@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@kernel.org \
--cc=tony.luck@intel.com \
/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