printk: introduce console_prepend_dropped() for dropped messages
authorJohn Ogness <john.ogness@linutronix.de>
Mon, 9 Jan 2023 10:07:58 +0000 (11:13 +0106)
committerPetr Mladek <pmladek@suse.com>
Wed, 11 Jan 2023 14:35:11 +0000 (15:35 +0100)
commitc4fcc617e148791fc45fd33b124301cb596bcbf6
tree668512d287559870a9a62766d142ec1311813356
parent2830eec14afd18c7af333b5222f47a1244adea11
printk: introduce console_prepend_dropped() for dropped messages

Currently "dropped messages" are separately printed immediately
before printing the printk message. Since normal consoles are
now using an output buffer that is much larger than previously,
the "dropped message" could be prepended to the printk message
and then output everything in a single write() call.

Introduce a helper function console_prepend_dropped() to prepend
an existing message with a "dropped message". This simplifies
the code by allowing all message formatting to be handled
together and then only requires a single write() call to output
the full message. And since this helper does not require any
locking, it can be used in the future for other console printing
contexts as well.

Note that console_prepend_dropped() is defined as a NOP for
!CONFIG_PRINTK. Although the function will never be called for
!CONFIG_PRINTK, compiling the function can lead to warnings of
"always true" conditionals due to the size macro values used
in !CONFIG_PRINTK.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20230109100800.1085541-7-john.ogness@linutronix.de
kernel/printk/internal.h
kernel/printk/printk.c