[GIT PULL] printk for 6.11

From: Petr Mladek
Date: Tue Jul 23 2024 - 10:38:39 EST


Hi Linus,

please pull the latest printk changes from

git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git tags/printk-for-6.11

===========================================

Next preparation step for introducing printk kthreads. This part
wires up flushing consoles via con->write_atomic() callback.

The write_atomic() callback can be used for flushing nbcon consoles
in any context. It is needed when the console could not be reliably
flushed using the printk kthread. Namely, it is used:

- During the early boot, from the legacy loop in console_unlock().
It allows to see the messages before processes (kthreads) could
get started.

Note that it must be used as long as there is a boot console
registered. The console_lock() serializes accesses to the same
HW port between the early and normal console driver.

- In an emergency section, directly from nbcon_cpu_emergency_exit()
or nbcon_cpu_emergency_flush(). It allows to see the messages
when the system is in an unexpected state and might not be
able to continue properly.

The messages are flushed at the end of the emergency section
to allow storing the full log (backtrace) first. It helps to
see it even when other CPUs add messages in parallel. The flush()
API is used to explicitly flush parts of longer logs which might
not fit into the buffer or might cause a softlockup.

The emergency section is used for WARN(), Oops, RCU stall,
and lockdep reports.

- In panic(), directly from printk() on the panic-CPU. Note that
other CPUs are not allowed to add new messages at this point.

There is also a new uart_port_lock() API in serial_core.h. It allows to
take port->lock and also acquire the nbcon console context when
the particular port gets registered as a console.

The port->lock serializes code for non-printing activities, for example,
for writing or setting the port speed. The nbcon context allows to
serialize the access in emergency or panic situations where the classic
spin lock (port->lock) could cause a deadlock. Note that the nbcon
context allows a safe takeover in the middle of a printed message.

IMPORTANT: The changes do not affect the behavior of legacy consoles,
except for two situations:

- Legacy consoles are not longer flushed directly from printk()
in emergency sections. The flush is done on exit from
the emergency section or by nbcon_cpu_emergency_flush().
The motivation is the same as for nbcon consoles.

- Legacy consoles are not longer flushed directly from printk()
in panic() when crash dump is created and a nbcon console
is registered. They could create a deadlock in compare with
nbcon consoles.

----------------------------------------------------------------
Jeff Johnson (1):
vsprintf: add missing MODULE_DESCRIPTION() macro

John Ogness (25):
printk: Add notation to console_srcu locking
printk: nbcon: Remove return value for write_atomic()
printk: nbcon: Add detailed doc for write_atomic()
printk: nbcon: Add callbacks to synchronize with driver
printk: nbcon: Use driver synchronization while (un)registering
serial: core: Provide low-level functions to lock port
serial: core: Introduce wrapper to set @uart_port->cons
console: Improve console_srcu_read_flags() comments
nbcon: Add API to acquire context for non-printing operations
serial: core: Implement processing in port->lock wrapper
printk: nbcon: Do not rely on proxy headers
printk: Make console_is_usable() available to nbcon
printk: Let console_is_usable() handle nbcon
printk: Add @flags argument for console_is_usable()
printk: nbcon: Add helper to assign priority based on CPU state
printk: Track registered boot consoles
printk: nbcon: Use nbcon consoles in console_flush_all()
printk: nbcon: Add unsafe flushing on panic
printk: Avoid console_lock dance if no legacy or boot consoles
printk: Track nbcon consoles
printk: Coordinate direct printing in panic
panic: Mark emergency section in oops
rcu: Mark emergency sections in rcu stalls
lockdep: Mark emergency sections in lockdep splats
printk: nbcon: do not require migration disabled for nbcon_get_cpu_emergency_nesting()

Petr Mladek (2):
printk: Properly deal with nbcon consoles on seq init
Merge branch 'rework/write-atomic' into for-linus

Sebastian Andrzej Siewior (1):
printk: Check printk_deferred_enter()/_exit() usage

Sreenath Vijayan (1):
printk: Rename console_replay_all() and update context

Thomas Gleixner (3):
printk: nbcon: Provide function to flush using write_atomic()
printk: nbcon: Implement emergency sections
panic: Mark emergency section in warn

drivers/tty/serial/8250/8250_core.c | 6 +-
drivers/tty/serial/amba-pl011.c | 2 +-
drivers/tty/serial/serial_core.c | 16 +-
drivers/tty/sysrq.c | 2 +-
include/linux/console.h | 112 ++++++--
include/linux/printk.h | 37 ++-
include/linux/serial_core.h | 117 +++++++-
kernel/locking/lockdep.c | 84 +++++-
kernel/panic.c | 9 +
kernel/printk/internal.h | 73 ++++-
kernel/printk/nbcon.c | 513 ++++++++++++++++++++++++++++++++++--
kernel/printk/printk.c | 313 ++++++++++++++++------
kernel/printk/printk_ringbuffer.h | 2 +
kernel/printk/printk_safe.c | 23 +-
kernel/rcu/tree_exp.h | 9 +
kernel/rcu/tree_stall.h | 11 +
lib/test_printf.c | 1 +
lib/test_scanf.c | 1 +
18 files changed, 1194 insertions(+), 137 deletions(-)