From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Donghyeok Choe <d7271.choe@samsung.com>,
linux-kernel@vger.kernel.org, takakura@valinux.co.jp,
youngmin.nam@samsung.com, hajun.sung@samsung.com,
seungh.jung@samsung.com, jh1012.choi@samsung.com
Subject: Re: printk: selective deactivation of feature ignoring non panic cpu's messages
Date: Tue, 4 Mar 2025 14:22:56 +0100 [thread overview]
Message-ID: <Z8b-ljGnw57GpJb0@pathway> (raw)
In-Reply-To: <8434fytakt.fsf@jogness.linutronix.de>
On Fri 2025-02-28 15:26:34, John Ogness wrote:
> On 2025-02-26, Petr Mladek <pmladek@suse.com> wrote:
> > I wonder if this is actually safe. I recall that we simplified the
> > design somewhere because we expected that non-panic CPUs will not
> > add messages.
>
> Perhaps you are recalling commit 7412dc6d55ee ("dump_stack: Do not get
> cpu_sync for panic CPU").
Yeah.
> > I am not sure that I found all locations. But
> > we might want to revise:
> >
> >
> > 1st problem: _prb_read_valid() skips non-finalized records on non-panic CPUs.
> >
> > opinion: We should not do it in this case.
>
> I don't know. This could result in seeing even less output if some CPU
> didn't finalize a record.
But it might also drop messages which are just being added.
And the person enabling the new option is explicitly interested
into the messages from non-panic CPUs.
To make it clear. I do not want to revert the change. But I would
avoid the skip when the new option is used.
The messages might be skipped later when CPUs are stopped.
The information is already available via the @legacy_allow_panic_sync
variable.
I mean something like:
--- a/kernel/printk/printk_ringbuffer.c
+++ b/kernel/printk/printk_ringbuffer.c
@@ -2143,7 +2143,9 @@ static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq,
* But it would have the sequence number returned
* by "prb_next_reserve_seq() - 1".
*/
- if (this_cpu_in_panic() && ((*seq + 1) < prb_next_reserve_seq(rb)))
+ if (this_cpu_in_panic() &&
+ (!printk_debug_non_panic_cpus || legacy_allow_panic_sync)
+ ((*seq + 1) < prb_next_reserve_seq(rb)))
(*seq)++;
else
return false;
Sigh, I am not much happy with the complexity. But if we did not
do it then people might have hard times to realize why the messages
from non-panic CPUs are skipped. Especially because this behavior is
pretty hidden in the log buffer code...
Another motivation is the thread about processing panic notifiers
before stopping CPU. It is still not clear whether it is really
needed. But it is another case where panic() did not work as
expected because a non-panic CPU did not finish a work,
see https://lore.kernel.org/all/20250221022328.47078-1-ryotkkr98@gmail.com/
> > 2nd problem: Is _prb_read_valid() actually safe when
> > panic_triggering_all_cpu_backtrace is true?
> >
> > opinion: It should be safe because the backtraces from different CPUs
> > are serialized via printk_cpu_sync_get_irqsave().
>
> To clarify, by "safe" you mean it does not skip backtrace records from
> other CPUs.
>
> It does not skip their records because trigger_all_cpu_backtrace() waits
> (up to 10 seconds) for the other CPUs to finish storing their backtraces
> before continuing.
OK, I propose the following changes:
+ rename the option to "printk_debug_non_panic_cpus"
+ do not skip the messages in _prb_read_valid() when this option
is used before the non-panic CPUs are stopped.
Best Regards,
Petr
next prev parent reply other threads:[~2025-03-04 13:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250226031756epcas2p3674cccc82687effb40575aa5fa2956e0@epcas2p3.samsung.com>
2025-02-26 3:16 ` printk: selective deactivation of feature ignoring non panic cpu's messages Donghyeok Choe
2025-02-26 4:25 ` John Ogness
2025-02-26 13:58 ` Petr Mladek
2025-02-28 14:20 ` John Ogness
2025-03-04 2:01 ` Donghyeok Choe
2025-03-04 13:22 ` Petr Mladek [this message]
2025-03-04 13:59 ` John Ogness
2025-03-04 14:15 ` Petr Mladek
2025-03-17 5:06 ` Donghyeok Choe
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=Z8b-ljGnw57GpJb0@pathway \
--to=pmladek@suse.com \
--cc=d7271.choe@samsung.com \
--cc=hajun.sung@samsung.com \
--cc=jh1012.choi@samsung.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=seungh.jung@samsung.com \
--cc=takakura@valinux.co.jp \
--cc=youngmin.nam@samsung.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