Re: [PATCH printk v1 00/10] printk: introduce atomic consoles and sync mode

From: Andy Shevchenko
Date: Tue Aug 03 2021 - 09:52:28 EST


On Tue, Aug 03, 2021 at 03:18:51PM +0206, John Ogness wrote:
> Hi,
>
> This is the next part of our printk-rework effort (points 3 and
> 4 of the LPC 2019 summary [0]).
>
> Here the concept of "atomic consoles" is introduced through a
> new (optional) write_atomic() callback for console drivers. This
> callback must be implemented as an NMI-safe variant of the
> write() callback, meaning that it can function from any context
> without relying on questionable tactics such as ignoring locking
> and also without relying on the synchronization of console
> semaphore.
>
> As an example of how such an atomic console can look like, this
> series implements write_atomic() for the 8250 UART driver.
>
> This series also introduces a new console printing mode called
> "sync mode" that is only activated when the kernel is about to
> end (such as panic, oops, shutdown, reboot). Sync mode can only
> be activated if atomic consoles are available. A system without
> registered atomic consoles will be unaffected by this series.
>
> When in sync mode, the console printing behavior becomes:
>
> - only consoles implementing write_atomic() will be called
>
> - printing occurs within vprintk_store() instead of
> console_unlock(), since the console semaphore is irrelevant
> for atomic consoles
>
> For systems that have registered atomic consoles, this series
> improves the reliability of seeing crash messages by using new
> locking techniques rather than "ignoring locks and hoping for
> the best". In particular, atomic consoles rely on the
> CPU-reentrant spinlock (i.e. the printk cpulock) for
> synchronizing console output.

If console is runtime suspended, who will bring it up?
Does it mean that this callback can't be implemented on the consoles that
do runtime suspend (some of 8250 currently, for example)?

--
With Best Regards,
Andy Shevchenko