]> git.ipfire.org Git - thirdparty/linux.git/commit
printk: remove logbuf_lock writer-protection of ringbuffer
authorJohn Ogness <john.ogness@linutronix.de>
Wed, 9 Dec 2020 00:44:53 +0000 (01:50 +0106)
committerPetr Mladek <pmladek@suse.com>
Wed, 9 Dec 2020 10:31:02 +0000 (11:31 +0100)
commitb031a684bfd01d633c79d281bd0cf11c2f834ada
treeca2ab9169fe3eba5a846f4cc02cef15395d55317
parent6b916706f8f09348cfa4fdd3642ebf87d6a2a26b
printk: remove logbuf_lock writer-protection of ringbuffer

Since the ringbuffer is lockless, there is no need for it to be
protected by @logbuf_lock. Remove @logbuf_lock writer-protection of
the ringbuffer. The reader-protection is not removed because some
variables, used by readers, are using @logbuf_lock for synchronization:
@syslog_seq, @syslog_time, @syslog_partial, @console_seq,
struct kmsg_dumper.

For PRINTK_NMI_DIRECT_CONTEXT_MASK, @logbuf_lock usage is not removed
because it may be used for dumper synchronization.

Without @logbuf_lock synchronization of vprintk_store() it is no
longer possible to use the single static buffer for temporarily
sprint'ing the message. Instead, use vsnprintf() to determine the
length and perform the real vscnprintf() using the area reserved from
the ringbuffer. This leads to suboptimal packing of the message data,
but will result in less wasted storage than multiple per-cpu buffers
to support lockless temporary sprint'ing.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20201209004453.17720-3-john.ogness@linutronix.de
kernel/printk/printk.c