From: Yazen Ghannam <yazen.ghannam@amd.com>
To: "Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>, Borislav Petkov <bp@kernel.org>,
linux-edac <linux-edac@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] EDAC/mce_amd: Do not print a stray newline
Date: Wed, 29 Jul 2026 15:52:27 -0400 [thread overview]
Message-ID: <20260729195227.GC1977085@yaz-khff2.amd.com> (raw)
In-Reply-To: <al2uZnOfkGxXv1q3@csail.mit.edu>
On Mon, Jul 20, 2026 at 10:43:10AM +0530, Srivatsa S. Bhat wrote:
[...]
> > > >
> > > > Yeah, Sashiko has a point:
> > > >
> > > > https://sashiko.dev/#/patchset/20260712031648.486110-1-bp%40kernel.org
> > > >
> > > > So we want the error records to be compact and fit in a block so that you can
> > > > recognize them easier and thus not print each thing with a newline.
> > > >
> > > > But those things are not unconditional so you cannot always know.
> > > >
> > > > I need to think of a slick scheme what to do here.
> > > >
> > >
> > > Do you mean something other than moving the newline print into an else
> > > block like this?
> > >
> > > ---
> > > drivers/edac/mce_amd.c | 10 +++++++---
> > > 1 file changed, 7 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c
> > > index bd252cb3c38e..60d1a62e1a95 100644
> > > --- a/drivers/edac/mce_amd.c
> > > +++ b/drivers/edac/mce_amd.c
> > > @@ -870,12 +870,16 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
> > > memcpy(&frutext[0], &err->vendor.amd.synd1, 8);
> > > memcpy(&frutext[8], &err->vendor.amd.synd2, 8);
> > >
> > > - pr_emerg(HW_ERR "FRU Text: %s", frutext);
> > > + pr_emerg(HW_ERR "FRU Text: %s\n", frutext);
> > > }
> > > + } else {
> > > + /*
> > > + * Explicit line termination to handle nested
> > > + * conditional prints correctly.
> > > + */
> > > + pr_cont("\n");
> > > }
> > >
> > > - pr_cont("\n");
> > > -
> > > decode_smca_error(m);
> > > goto err_code;
> > > }
> > > --
> >
> > Another option could be to build up each newline string and print it
> > once. The gist is to get rid of pr_cont() usage.
> >
>
> I don't think getting rid of pr_cont() was the intention behind the
> original patch by Boris; he was trying to address a user-visible
> stray newline in the logs, if I understood correctly.
Correct. Though the issue may be resolved with other rework.
>
> > I've attached an old patch for that. Would this work?
> >
>
> The approach to build up each string fully before printing it that you
> demonstrated below does look like a nice improvement in general, but
> I'm afraid it may not be a good fit for this particular subsystem
> though, for the following reasons:
>
> 1. Given the EDAC subsystem's role in handling/reporting hardware
> errors, I think the logging preference for this subsystem would be
> to get the error message out as soon as possible, as the machine is
> already likely to be in trouble if we are printing out kernel logs at
> the criticality level of "emergency". So, delaying these prints to
> construct the full string may not be desirable, as doing so can
> potentially cripple the ability to get even the error indicators
> known upto that point printed out (in case of further occurrence of
> hardware errors).
These EDAC messages are a convenience to the user and are not indicative
of the severity.
In fact, this is another low priority item I think should be addressed.
The "printk" log level could be linked to the error severity. For
example, "info" for corrected errors and "warning" for uncorrected
errors. It is not rational to treat all decoded errors with "emergency"
log level.
The x86 EDAC modules listen on the MCE notifier chain. If there is time
for EDAC to decode, then the event is not an emergency.
>
> 2. The static buffer sizing for the character string (256) is
> potentially prone to buffer overflows in the future as and when these
> print statements evolve (without taking the buffer size into
> careful consideration for every change to the string).
Yes, that's the goal of patch review.
>
> 3. This is a much larger (cleanup) change than what Boris had posted
> earlier (which was ~2 lines).
>
Yes, sometimes simple issues lead to larger cleanup.
Thanks,
Yazen
prev parent reply other threads:[~2026-07-29 19:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 3:16 [PATCH] EDAC/mce_amd: Do not print a stray newline Borislav Petkov
2026-07-13 18:44 ` Yazen Ghannam
2026-07-13 23:22 ` Borislav Petkov
2026-07-14 10:28 ` Srivatsa S. Bhat
2026-07-14 13:04 ` Yazen Ghannam
2026-07-20 5:13 ` Srivatsa S. Bhat
2026-07-29 19:52 ` Yazen Ghannam [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=20260729195227.GC1977085@yaz-khff2.amd.com \
--to=yazen.ghannam@amd.com \
--cc=bp@alien8.de \
--cc=bp@kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srivatsa@csail.mit.edu \
/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