[PATCH next v2 0/3] printk: remove logbuf_lock

From: John Ogness
Date: Tue Dec 01 2020 - 15:54:35 EST


Hello,

Here is a v2 of the next series for the printk-rework. It
removes the @logbuf_lock. v1 is here [0]. Since this lock
protected more than just the ringbuffer, a new
finer-grained @syslog_lock is introduced.

With this series, vprintk_store() becomes lockless.

A consequence of this locklessness is that a buffer for
temporary sprint space is no longer available. To get
around this, vsnprintf() is used to determine the full
length to reserve in the ringbuffer and then the message is
directly sprint'ed to the reserved space.

Since the sprint'ed message may include syslog prefix and
newline (both of which get stripped), there will be some
bytes of wasted space per message. This space could be
reclaimed by introducing a "trimming function" to the
ringbuffer, which could reduce the size of a reserved data
block if no newer block is reserved. However, such a
function is not part of this series.

This series falls in line with the printk-rework plan as
presented [1] at Linux Plumbers in Lisbon 2019.

The series is based on next-20201201.

John Ogness

[0] https://lkml.kernel.org/r/20200922153816.5883-1-john.ogness@xxxxxxxxxxxxx
[1] https://linuxplumbersconf.org/event/4/contributions/290/attachments/276/463/lpc2019_jogness_printk.pdf (slide 23)

John Ogness (3):
printk: inline log_output(),log_store() in vprintk_store()
printk: change @clear_seq to atomic64_t
printk: remove logbuf_lock, add syslog_lock

include/linux/printk.h | 1 +
kernel/printk/internal.h | 4 +-
kernel/printk/printk.c | 411 ++++++++++++++++++------------------
kernel/printk/printk_safe.c | 18 +-
4 files changed, 212 insertions(+), 222 deletions(-)

--
2.20.1