mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lin Junzhe <m18667909625@163.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: linux-kernel@vger.kernel.org
Cc: m18667909625@163.com
Subject: Re: [PATCH] printk: fold consecutive duplicate messages
Date: Sun, 21 Sep 2026 18:30:00 +0800	[thread overview]
Message-ID: <20260921183000.1-m18667909625@163.com> (raw)
In-Reply-To: <875wzzoxcd.fsf@jogness.linutronix.de>

Hi John,

Thanks for the review.

> Could you provide some examples of consoles being flooded with
> the same message? Doesn't sound like a real case to me.

Real cases I have seen in the field and in bug reports:

1. GPU faults (nouveau): a misbehaving userspace program or a dying
   GPU can trigger a stream of identical fault reports from the
   in-tree nouveau driver, e.g. repeated "fifo: fault at ..." lines
   while the offending context keeps being rescheduled. Similar
   spam exists for other GPU drivers when a fence or scheduler
   loop misbehaves.

2. Failing storage: a dying SATA disk produces endless identical
   "ata1.00: failed command" / "ata1: SError" storms. This is a
   classic dmesg flood that buries everything else on machines
   with a serial console and no syslogd.

3. USB reset loops: a flaky cable or port makes the USB stack
   repeatedly print the identical "usb X-Y: reset <speed> USB
   device number N using <hcd>" line, sometimes for minutes.

4. IRQ storms: an unhandled level-triggered interrupt prints the
   identical "irq N: nobody cared" report for every retrigger
   until the IRQ is disabled.

In all four cases the messages come from kernel-side ratelimits or
error paths that repeat at line rate, and on systems where the only
observable output is the kernel console (serial console, early boot,
netconsole), no userspace dedup exists to save the log.

> printk is NMI safe and lockless. It needs to remain so.

Fully agreed, and thank you for the clear statement. My
implementation takes a raw spinlock in vprintk_emit(), which
violates exactly that invariant -- the in_nmi() guard only avoids
the deadlock by disabling the feature where it would be most
dangerous, which is not acceptable either.

Given this, I see two options:

a) I drop the patch entirely; or

b) I rework the idea as lockless per-CPU/per-console state at the
   console output layer (or on top of nbcon), so the printk
   fast path stays lock- and NMI-safe.

Please tell me whether (b) is worth exploring or whether the
consensus is that deduplication belongs in userspace and (a) is
the right outcome. Either way is fine with me.

Best regards,
林濬哲

--
Assisted-by: AI coding assistant (disclosed per kernel AI guidelines)

  reply	other threads:[~2026-09-21 10:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  5:03 林濬哲
2026-09-21  7:52 ` John Ogness
2026-09-21 10:30   ` Lin Junzhe [this message]
2026-09-21 12:13     ` John Ogness
2026-09-21 14:40       ` Lin Junzhe
2026-09-23  9:43       ` Petr Mladek
2026-09-23 20:59 ` kernel test robot
2026-09-23 21:34 ` kernel test robot

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=20260921183000.1-m18667909625@163.com \
    --to=m18667909625@163.com \
    --cc=john.ogness@linutronix.de \
    --cc=pmladek@suse.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

all inboxes | Powered by JetHome®