From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Breno Leitao <leitao@debian.org>,
linux@armlinux.org.uk, paulmck@kernel.org,
usamaarif642@gmail.com, leo.yan@arm.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
rmikey@meta.com
Subject: Re: CSD lockup during kexec due to unbounded busy-wait in pl011_console_write_atomic (arm64)
Date: Tue, 2 Dec 2025 11:34:15 +0100 [thread overview]
Message-ID: <aS7ApzJG8RPhtKh5@pathway.suse.cz> (raw)
In-Reply-To: <87bjkificj.fsf@jogness.linutronix.de>
On Mon 2025-12-01 14:27:32, John Ogness wrote:
> On 2025-12-01, John Ogness <john.ogness@linutronix.de> wrote:
> >> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> >> index 3fa403f9831f..6b8becb6ecd9 100644
> >> --- a/kernel/printk/nbcon.c
> >> +++ b/kernel/printk/nbcon.c
> >> @@ -1549,6 +1549,7 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
> >> {
> >> struct nbcon_write_context wctxt = { };
> >> struct nbcon_context *ctxt = &ACCESS_PRIVATE(&wctxt, ctxt);
> >> + unsigned long flags;
> >> int err = 0;
> >>
> >> ctxt->console = con;
> >> @@ -1557,18 +1558,31 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
> >> ctxt->allow_unsafe_takeover = nbcon_allow_unsafe_takeover();
> >>
> >> while (nbcon_seq_read(con) < stop_seq) {
> >> - if (!nbcon_context_try_acquire(ctxt, false))
> >> + /*
> >> + * Atomic flushing does not use console driver synchronization
> >> + * (i.e. it does not hold the port lock for uart consoles).
> >> + * Therefore IRQs must be disabled to avoid being interrupted
> >> + * and then calling into a driver that will deadlock trying
> >> + * to acquire console ownership.
> >> + */
> >> + local_irq_save(flags);
> >> + if (!nbcon_context_try_acquire(ctxt, false)) {
> >> + local_irq_restore(flags);
> >> return -EPERM;
> >> + }
> >>
> >> /*
> >> * nbcon_emit_next_record() returns false when the console was
> >> * handed over or taken over. In both cases the context is no
> >> * longer valid.
> >> */
> >> - if (!nbcon_emit_next_record(&wctxt, true))
> >> + if (!nbcon_emit_next_record(&wctxt, true)) {
> >> + local_irq_restore(flags);
> >> return -EAGAIN;
> >> + }
> >>
> >> nbcon_context_release(ctxt);
> >> + local_irq_restore(flags);
> >
> > Using local_irq_save()/_restore() here is not acceptable for PREEMPT_RT
> > because __nbcon_atomic_flush_pending_con() is also used by
> > nbcon_device_release().
Great catch! I did not think about this code path.
> After thinking about this more, this would be acceptable. If
> printk_get_console_flush_type() is reporting nbcon_atomic==true, then
> the system is in a state where latencies are irrelevant.
I agree. It might be possible to create a special variant for
the nbcon_device_release() code path. But it probably is not
worth it.
I am going to mention this in the commit message and send
it as proper patch.
Thanks a lot for review and feedback.
Best Regards,
Petr
next prev parent reply other threads:[~2025-12-02 10:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 16:02 CSD lockup during kexec due to unbounded busy-wait in pl011_console_write_atomic (arm64) Breno Leitao
2025-11-26 14:13 ` Breno Leitao
2025-11-26 14:54 ` Marco Elver
2025-11-26 15:54 ` Breno Leitao
2025-11-26 16:08 ` Marco Elver
2025-11-26 16:37 ` Breno Leitao
2025-11-28 16:08 ` Petr Mladek
2025-12-01 12:58 ` John Ogness
2025-12-01 13:21 ` John Ogness
2025-12-02 10:34 ` Petr Mladek [this message]
2025-12-01 17:04 ` Breno Leitao
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=aS7ApzJG8RPhtKh5@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=john.ogness@linutronix.de \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=paulmck@kernel.org \
--cc=rmikey@meta.com \
--cc=usamaarif642@gmail.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