[PATCH printk v1 00/10] printk: introduce atomic consoles and sync mode
Petr Mladek
pmladek at suse.com
Fri Aug 6 01:47:22 AEST 2021
On Tue 2021-08-03 15:18:51, 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
I am fine with the new behavior at this stage. It is a quite clear
win when (only) the atomic console is used. And it does not make any
difference when atomic consoles are disabled.
But I am not sure about the proposed terms and implementation.
I want to be sure that we are on the right way for introducing
console kthreads.
Let me try to compare the behavior:
1. before this patchset():
/* printk: store immediately; try all consoles immediately */
int printk(...)
{
vprintk_store();
if (console_try_lock()) {
/* flush pending messages to the consoles */
console_unlock();
}
}
/* panic: try hard to flush messages to the consoles and avoid deadlock */
void panic()
{
/* Ignore locks in console drivers */
bust_spinlocks(1);
printk("Kernel panic ...);
dump_stack();
smp_send_stop();
/* ignore console lock */
console_flush_on_panic();
}
2. after this patchset():
+ same as before in normal mode or when there is no atomic console
+ in panic with atomic console; it modifies the behavior:
/*
* printk: store immediately; immediately flush atomic consoles;
* unsafe consoles are not used anymore;
*/
int printk(...)
{
vprintk_store();
flush_atomic_consoles();
}
/* panic: no hacks; only atomic consoles are used */
void panic()
{
printk("Kernel panic ...);
dump_stack();
}
3. After introducing console kthread(s):
int printk(...)
{
vprintk_store();
wake_consoles_via_irqwork();
}
+ in panic:
+ with atomic console like after this patchset?
+ without atomic consoles?
+ during early boot?
I guess that we will need another sync mode for the early boot,
panic, suspend, kexec, etc.. It must be posible to debug these states
even wihtout atomic console and working kthreads.
Best Regards,
Petr
More information about the Linuxppc-dev
mailing list