[PATCH printk v3 0/7] provide nbcon base

From: John Ogness
Date: Sun Sep 03 2023 - 11:05:50 EST


Hi,

This is v3 of a series to introduce the new non-BKL (nbcon)
consoles. v2 is here [0]. For information about the motivation
of the atomic consoles, please read the cover letter of v1 [1].

This series focuses on providing the base functionality of the
nbcon consoles. In particular, it implements the ownership and
priority semantics for nbcon consoles. This series does _not_
include threaded printing, atomic printing regions, or nbcon
drivers. Those features will be added in separate follow-up
series.

The changes since v2:

- rename nbcon_state::hostile_unsafe to
nbcon_state::unsafe_takeover

- add 2-bit nbcon_state::req_tag to help identify waiters

- remove nbcon_context::unsafe

- remove nbcon_context::hostile

- rename nbcon_context::takeover_unsafe to
nbcon_context::allow_unsafe_takeover

- callers must now check the current console state to see if it
acquired the console using the unsafe hostile takeover method

- rename nbcon_write_context::hostile_unsafe to
nbcon_write_context::unsafe_takeover

- allow direct takeover of owned consoles if higher priority
and safe

- rename printk_nbcon.c to nbcon.c

- remove most printk.c changes, to be added in a later series
once all the nbcon functionality is implemented (only init
and seq updates/checks are kept)

- add nbcon_alloc() to be called early in register_console() to
allow for simple backout on failure (nbcon_init() changed to
return void)

- remove my special debugging because it was annoying

- rename __nbcon_seq_to_stored() to __seq_to_nbcon_seq()

- rename __nbcon_seq_to_full() to __nbcon_seq_to_seq()

- implement seq translation as suggested by pmladek

- in nbcon_seq_try_update(), unconditionally attempt cmpxchg to
allow CONSOLE_REPLAY_ALL to work

- change semantics of all acquire methods to simplify the model

- add nbcon_waiter_matches() to check waiter based on prio and
req_tag

- add nbcon_context_try_acquire_requested() to implement
handover part of acquiring after setting request

- in nbcon_context_update_unsafe(), perform handover when
transitioning to !unsafe and there is a waiter

- in nbcon_emit_next_record(), simplify initializing @wctxt

- in nbcon_emit_next_record(), set the console state to unsafe
while updating @dropped and @nbcon_seq to avoid data race
when not in panic

- cleanup comments as suggested by pmladek

John Ogness

[0] https://lore.kernel.org/lkml/20230728000233.50887-1-john.ogness@xxxxxxxxxxxxx

[1] https://lore.kernel.org/lkml/20230302195618.156940-6-john.ogness@xxxxxxxxxxxxx

Thomas Gleixner (7):
printk: Add non-BKL (nbcon) console basic infrastructure
printk: nbcon: Add acquire/release logic
printk: nbcon: Add buffer management
printk: nbcon: Add ownership state functions
printk: nbcon: Add sequence handling
printk: nbcon: Add emit function and callback function for atomic
printing
printk: nbcon: Add functions for drivers to mark unsafe regions

include/linux/console.h | 135 ++++++
kernel/printk/Makefile | 2 +-
kernel/printk/internal.h | 29 ++
kernel/printk/nbcon.c | 945 +++++++++++++++++++++++++++++++++++++++
kernel/printk/printk.c | 60 ++-
5 files changed, 1152 insertions(+), 19 deletions(-)
create mode 100644 kernel/printk/nbcon.c


base-commit: cb65d08d735e00cc55ad7700a82a453bb88c93a3
--
2.39.2