From: Gustavo Luiz Duarte <gustavold@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Rio <rioo.tsukatsukii@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1] panic: Flush unsafe consoles before panic reboot
Date: Thu, 22 Oct 2026 21:35:35 +0100 [thread overview]
Message-ID: <179270133563.1870306.14879054140316608291.b4-reply@b4> (raw)
In-Reply-To: <aqqU3I7d9lMAjSvy@pathway.suse.cz>
On 2026-09-16 15:08:44+02:00, Petr Mladek wrote:
> On Tue 2026-09-15 11:01:38, Ryan Roberts wrote:
>
> > Netconsole registers with CON_NBCON_ATOMIC_UNSAFE, so its write_atomic()
> > callback is only usable during nbcon_atomic_flush_unsafe(). Previously
> > this was only called by vpanic() if panic_timeout=0 - i.e. if the system
> > was configured not to reboot on panic. So if the system was configured
> > to reboot on panic, netconsole would never receive the panic logs.
> >
> > Move vpanic()'s emergency_restart() call to after the call to
> > nbcon_atomic_flush_unsafe() to solve this problem. The downside is that
> > potentially unsafe operations are now performed prior to
> > emergency_restart() which could theoretically reduce the chances of the
> > restart succeeding. But we are already in a panic situation so it could
> > be argued that everything is best effort already.
>
> The panic() code is like walking on bumpy roads. It tries to be as
> safe as possible. IMHO, it has few important tasks:
>
> + show debug messages
> + create crash dump (optional)
> + safely reboot (optional)
>
> The debug messages are important but some users might prioritize
> reboot over the debug messages. It helps when the panic() is rare
> (low likely race) and the system is quickly able to handle the load
> after the reboot.
>
> This is why we put nbcon_atomic_flush_unsafe() only into the path
> which ends with an infinite loop.
>
> > In older kernels (v6.19 and earlier) netconsole is able to print these
> > panic logs while the system is configured to reboot on panic. So from a
> > user perspective this is a regression caused by commit 7eab73b18630
> > ("netconsole: convert to NBCON console infrastructure").
> >
> > We have automated test systems without BMC access, which rely on these
> > two features working together.
>
> I see. To be precise, I would say that the primary culprit is the
> commit 187de7c212e5fa87 ("printk: nbcon: Allow unsafe write_atomic()
> for panic"). It adds support for consoles which will be flushed
> in panic() only by nbcon_atomic_flush_unsafe().
>
> It is a big difference because printk() tries to flush both
> legacy and "safe" NBCON consoles directly in panic(). In addition,
> they are explicitely flushed by console_flush_on_panic().
>
> console_flush_on_panic() is called more times in panic().
> And it tries to flush legacy consoles the unsafe way even
> before emergency_restart().
>
> OK, we should close this gap. But I suggest another solution.
>
> We already have the following functions for flushing NBCON
> consoles using write_atomic()
>
>
> + nbcon_atomic_flush_pending() - flush CON_NBCON consoles
> using con->write_atomic() but only when safe
>
> + nbcon_atomic_flush_unsafe() - flush CON_NBCON consoles
> using con->write_atomic() and allow unsafe takeover.
>
> I suggest to add 3rd variant, for example:
>
> + nbcon_atomic_unsafe_flush_unsafe() - flush
> CON_NBCON_ATOMIC_UNSAFE consoles with con->write_atomic()
> and allow unsafe takeover.
>
> And I would call this 3rd variant in console_flush_on_panic(),
> something like:
>
> void console_flush_on_panic(enum con_flush_mode mode)
> {
> [...]
> printk_get_console_flush_type(&ft);
> if (ft.nbcon_atomic) {
> nbcon_atomic_flush_pending();
> nbcon_atomic_unsafe_flush_unsafe();
> }
>
> /* Flush legacy consoles once allowed, even when dangerous. */
> if (legacy_allow_panic_sync)
> console_flush_all(false, &next_seq, &handover);
> }
>
> But maybe, this is over engineered and we should just call
> nbcon_atomic_flush_unsafe() in console_flush_on_panic(), like:
>
> void console_flush_on_panic(enum con_flush_mode mode)
> {
> [...]
> printk_get_console_flush_type(&ft);
> if (ft.nbcon_atomic) {
> nbcon_atomic_flush_pending();
> nbcon_atomic_flush_unsafe();
> }
>
> /* Flush legacy consoles once allowed, even when dangerous. */
> if (legacy_allow_panic_sync)
> console_flush_all(false, &next_seq, &handover);
> }
Hi Ryan, are you still planning to send a non-RFC patch? If not, I'm
happy to take over and send a patch with Petr's suggestion.
We are seeing cases in production of panic logs not reaching netconsole
because of this.
next prev parent reply other threads:[~2026-10-22 20:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 10:01 Ryan Roberts
2026-09-15 10:06 ` Ryan Roberts
2026-09-15 18:49 ` Bradley Morgan
2026-09-16 7:44 ` Ryan Roberts
2026-09-16 14:58 ` Bradley Morgan
2026-09-16 13:08 ` Petr Mladek
2026-10-22 20:35 ` Gustavo Luiz Duarte [this message]
2026-10-23 7:57 ` John Ogness
2026-10-23 10:36 ` Petr Mladek
2026-10-27 16:12 ` Breno Leitao
2026-10-27 17:43 ` Breno Leitao
2026-10-27 18:01 ` John Ogness
2026-10-28 11:24 ` Breno Leitao
2026-10-28 10:52 ` Breno Leitao
2026-10-28 14:37 ` John Ogness
2026-10-28 21:15 ` Breno Leitao
2026-10-29 9:20 ` John Ogness
2026-10-29 10:58 ` Breno Leitao
2026-10-29 13:53 ` John Ogness
2026-10-29 14:37 ` Petr Mladek
2026-10-30 17:56 ` Breno Leitao
2026-11-02 10:28 ` Petr Mladek
2026-11-02 13:27 ` Breno Leitao
2026-11-02 22:22 ` John Ogness
2026-11-03 13:31 ` Petr Mladek
2026-11-04 11:18 ` John Ogness
2026-11-05 16:50 ` Petr Mladek
2026-11-05 19:01 ` John Ogness
2026-11-02 22:14 ` John Ogness
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=179270133563.1870306.14879054140316608291.b4-reply@b4 \
--to=gustavold@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rioo.tsukatsukii@gmail.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=senozhatsky@chromium.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®