[printk,v3,0/6] printk: cleanup buffer handling

Message ID 20221221202704.857925-1-john.ogness@linutronix.de
Headers
Series printk: cleanup buffer handling |

Message

John Ogness Dec. 21, 2022, 8:26 p.m. UTC
  Hi,

This is v3 of a series to cleanup console buffer handling and
prepare for code sharing with the upcoming threaded/atomic
consoles. v2 is here [0].

The main purpose of the series is to introduce 2 new lockless
functions to handle all console formatting of printk messages. These
functions can then be used from any context, which is important for
the upcoming threaded/atomic consoles. The series also helps to
cleanup some of the internal printk interfaces and cleanly separate
formatting code from outputting code.

Changes since v2:

- Put size limit macros and definitions of structs console_buffers
  and console_message in printk/internal.h instead of
  linux/console.h.

- Provide a better description for @dropped field of struct console.
  (Only a small change in patch 3/6. I kept Petr's Reviewed-by tag.)

- Move the static struct console_buffers inside
  console_emit_next_record() since this function will not be used by
  the threaded/atomic consoles.

- Rename various functions and struct fields:

    msg_print_dropped()       ->  console_prepend_dropped()

    console_buffers.ext_text  ->  console_buffers.outbuf

    console_buffers.text      ->  console_buffers.scratchbuf

- console_buffers.outbuf is always the output buffer.

- Change struct console_message fields:

    removed: char *outbuf

    removed: bool is_extmsg

    added:   u64 outbuf_seq

    added:   unsigned long dropped

- All struct console_message fields are now output fields. No input
  fields.

- Implement console_prepend_dropped() as suggested by pmladek: shift
  existing message and insert dropped message.

- For console_get_next_message():

    add all input variables as arguments

    do not rely on locking (no @console argument)

    do not prepend "dropped messages", let the caller deal with that

    implement as suggested by pmladek: use different buffers for
    ringbuffer reading so that @outbuf is always the output buffer
    in the end

- Do not use struct console_buffers for devkmsg. (It is not a
  console).

John Ogness

[0] https://lore.kernel.org/lkml/20221123231400.614679-1-john.ogness@linutronix.de

John Ogness (4):
  printk: move size limit macros into internal.h
  printk: introduce struct console_buffers
  printk: introduce console_get_next_message() and console_message
  printk: introduce console_prepend_dropped() for dropped messages

Thomas Gleixner (2):
  console: Use BIT() macros for @flags values
  console: Document struct console

 include/linux/console.h  | 100 ++++++++++++-----
 include/linux/printk.h   |   2 -
 kernel/printk/internal.h |  45 ++++++++
 kernel/printk/printk.c   | 237 +++++++++++++++++++++++----------------
 4 files changed, 260 insertions(+), 124 deletions(-)


base-commit: 6b2b0d839acaa84f05a77184370f793752e786e9