All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrea Parri <parri.andrea@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paul McKenney <paulmck@kernel.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v4 0/4] printk: replace ringbuffer
Date: Tue,  7 Jul 2020 17:05:28 +0206	[thread overview]
Message-ID: <20200707145932.8752-1-john.ogness@linutronix.de> (raw)

Hello,

Here is a v4 for the first series to rework the printk
subsystem. The v3 is here [0]. This first series
only replaces the existing ringbuffer implementation. No locking
is removed. The semantics/behavior of printk are kept the same
except for a minor optimization that is reverted (patch 3).

Despite minor changes to the ringbuffer code since v3 (comments,
function names, very minor refactoring), the ringbuffer logic
itself has not changed. And, in particular, the memory barriers
have been exactly preserved from v3. For this reason I deem it
appropriate to keep Paul's reviewed by tag (patch 2).

RFC patches for various userspace tools to dump the kernel log
are available: crash [1], makedumpfile [2], kexec-tools [3].

Finally, I would like to thank some people/organizations that
helped with performing ringbuffer stress tests on big or rare
hardware that I do not have access to:

- Prarit Bhargava of Red Hat (x86_64, ppc64le power8)
- Michael Cree of Debian (alpha)
- Jeff Scheel of OSU Open Source Lab (ppc64le power8 kvm)

These tests were extremely valuable during the memory barrier
work. Thank you!

This series is based on v5.8-rc4.

The list of changes since v3:

printk_ringbuffer
=================

- data_alloc(): remove unneeded check for a NULL data ring [4]

- prb_next_seq(): simplified by assuming u64 never overflows [4]

- added prb_for_each_info() macro to iterate record meta-data [5]

- prb_count_lines() renamed to count_lines() and is now a static
  helper function [5]

- buffers defined by DECLARE_PRINTKRB() now static [6]

- DECLARE_PRINTKRB() renamed to DEFINE_PRINTKRB() because it is
  defining, not declaring

printk.c
========

- added a compiler macro test to ensure CONFIG_LOG_BUF_SHIFT
  is greater than PRB_AVGBITS [7]

- setup_log_buf(): fixed handling of failed allocation of the
  dictionary data ring [7]

- setup_log_buf(): now verify that no messages were dropped
  during the transition to the dynamic buffer [7]

- setup_log_buf(): added size checks, comments, and temporary
  variables to clean up the code [7]

- setup_log_buf(): use ilog2() instead of order_base_2() [8]

- truncate_msg(): no longer truncate dictionary data [9]

- record_print_text(): refactored code and comments [10]

- get_record_text_size() renamed to
  get_record_print_text_size() [11]

- use prb_for_each_info() instead of prb_count_lines() to get
  the number of lines in a message (also avoids unnecessarily
  allocating buffer space and/or copying message text) [5]

- reverted printk optimization to only wake klogd if
  vprintk_emit() actually produced new printing content [12]

[0] https://lkml.kernel.org/r/20200618144919.9806-1-john.ogness@linutronix.de
[1] https://github.com/Linutronix/crash.git (printk branch)
[2] https://github.com/Linutronix/makedumpfile.git (printk branch)
[3] https://github.com/Linutronix/kexec-tools.git (printk branch)
[4] https://lkml.kernel.org/r/20200702083518.GB14288@alley
[5] https://lkml.kernel.org/r/87k0zp8rrn.fsf@jogness.linutronix.de
[6] https://lkml.kernel.org/r/20200619082919.5d604e58@oasis.local.home
[7] https://lkml.kernel.org/r/87sgeh3m5j.fsf@jogness.linutronix.de
[8] https://lkml.kernel.org/r/20200702132758.GD14288@alley
[9] https://lkml.kernel.org/r/87wo3u2b0l.fsf@jogness.linutronix.de
[10] https://lkml.kernel.org/r/87k0ztbea9.fsf@jogness.linutronix.de
[11] https://lkml.kernel.org/r/20200625152523.GJ8444@alley
[12] https://lkml.kernel.org/r/87o8oznh2c.fsf@jogness.linutronix.de

John Ogness (4):
  crash: add VMCOREINFO macro to define offset in a struct declared by
    typedef
  printk: add lockless ringbuffer
  Revert "printk: lock/unlock console only for new logbuf entries"
  printk: use the lockless ringbuffer

 include/linux/crash_core.h        |    3 +
 kernel/printk/Makefile            |    1 +
 kernel/printk/printk.c            |  950 ++++++++--------
 kernel/printk/printk_ringbuffer.c | 1676 +++++++++++++++++++++++++++++
 kernel/printk/printk_ringbuffer.h |  399 +++++++
 5 files changed, 2575 insertions(+), 454 deletions(-)
 create mode 100644 kernel/printk/printk_ringbuffer.c
 create mode 100644 kernel/printk/printk_ringbuffer.h

-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: Andrea Parri <parri.andrea@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Paul McKenney <paulmck@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH v4 0/4] printk: replace ringbuffer
Date: Tue,  7 Jul 2020 17:05:28 +0206	[thread overview]
Message-ID: <20200707145932.8752-1-john.ogness@linutronix.de> (raw)

Hello,

Here is a v4 for the first series to rework the printk
subsystem. The v3 is here [0]. This first series
only replaces the existing ringbuffer implementation. No locking
is removed. The semantics/behavior of printk are kept the same
except for a minor optimization that is reverted (patch 3).

Despite minor changes to the ringbuffer code since v3 (comments,
function names, very minor refactoring), the ringbuffer logic
itself has not changed. And, in particular, the memory barriers
have been exactly preserved from v3. For this reason I deem it
appropriate to keep Paul's reviewed by tag (patch 2).

RFC patches for various userspace tools to dump the kernel log
are available: crash [1], makedumpfile [2], kexec-tools [3].

Finally, I would like to thank some people/organizations that
helped with performing ringbuffer stress tests on big or rare
hardware that I do not have access to:

- Prarit Bhargava of Red Hat (x86_64, ppc64le power8)
- Michael Cree of Debian (alpha)
- Jeff Scheel of OSU Open Source Lab (ppc64le power8 kvm)

These tests were extremely valuable during the memory barrier
work. Thank you!

This series is based on v5.8-rc4.

The list of changes since v3:

printk_ringbuffer
=================

- data_alloc(): remove unneeded check for a NULL data ring [4]

- prb_next_seq(): simplified by assuming u64 never overflows [4]

- added prb_for_each_info() macro to iterate record meta-data [5]

- prb_count_lines() renamed to count_lines() and is now a static
  helper function [5]

- buffers defined by DECLARE_PRINTKRB() now static [6]

- DECLARE_PRINTKRB() renamed to DEFINE_PRINTKRB() because it is
  defining, not declaring

printk.c
========

- added a compiler macro test to ensure CONFIG_LOG_BUF_SHIFT
  is greater than PRB_AVGBITS [7]

- setup_log_buf(): fixed handling of failed allocation of the
  dictionary data ring [7]

- setup_log_buf(): now verify that no messages were dropped
  during the transition to the dynamic buffer [7]

- setup_log_buf(): added size checks, comments, and temporary
  variables to clean up the code [7]

- setup_log_buf(): use ilog2() instead of order_base_2() [8]

- truncate_msg(): no longer truncate dictionary data [9]

- record_print_text(): refactored code and comments [10]

- get_record_text_size() renamed to
  get_record_print_text_size() [11]

- use prb_for_each_info() instead of prb_count_lines() to get
  the number of lines in a message (also avoids unnecessarily
  allocating buffer space and/or copying message text) [5]

- reverted printk optimization to only wake klogd if
  vprintk_emit() actually produced new printing content [12]

[0] https://lkml.kernel.org/r/20200618144919.9806-1-john.ogness@linutronix.de
[1] https://github.com/Linutronix/crash.git (printk branch)
[2] https://github.com/Linutronix/makedumpfile.git (printk branch)
[3] https://github.com/Linutronix/kexec-tools.git (printk branch)
[4] https://lkml.kernel.org/r/20200702083518.GB14288@alley
[5] https://lkml.kernel.org/r/87k0zp8rrn.fsf@jogness.linutronix.de
[6] https://lkml.kernel.org/r/20200619082919.5d604e58@oasis.local.home
[7] https://lkml.kernel.org/r/87sgeh3m5j.fsf@jogness.linutronix.de
[8] https://lkml.kernel.org/r/20200702132758.GD14288@alley
[9] https://lkml.kernel.org/r/87wo3u2b0l.fsf@jogness.linutronix.de
[10] https://lkml.kernel.org/r/87k0ztbea9.fsf@jogness.linutronix.de
[11] https://lkml.kernel.org/r/20200625152523.GJ8444@alley
[12] https://lkml.kernel.org/r/87o8oznh2c.fsf@jogness.linutronix.de

John Ogness (4):
  crash: add VMCOREINFO macro to define offset in a struct declared by
    typedef
  printk: add lockless ringbuffer
  Revert "printk: lock/unlock console only for new logbuf entries"
  printk: use the lockless ringbuffer

 include/linux/crash_core.h        |    3 +
 kernel/printk/Makefile            |    1 +
 kernel/printk/printk.c            |  950 ++++++++--------
 kernel/printk/printk_ringbuffer.c | 1676 +++++++++++++++++++++++++++++
 kernel/printk/printk_ringbuffer.h |  399 +++++++
 5 files changed, 2575 insertions(+), 454 deletions(-)
 create mode 100644 kernel/printk/printk_ringbuffer.c
 create mode 100644 kernel/printk/printk_ringbuffer.h

-- 
2.20.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2020-07-07 14:59 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 14:59 John Ogness [this message]
2020-07-07 14:59 ` [PATCH v4 0/4] printk: replace ringbuffer John Ogness
2020-07-07 14:59 ` [PATCH v4 1/4] crash: add VMCOREINFO macro to define offset in a struct declared by typedef John Ogness
2020-07-07 14:59   ` John Ogness
2020-07-07 14:59 ` [PATCH v4 2/4] printk: add lockless ringbuffer John Ogness
2020-07-07 14:59   ` John Ogness
2020-07-07 14:59 ` [PATCH v4 3/4] Revert "printk: lock/unlock console only for new logbuf entries" John Ogness
2020-07-07 14:59   ` John Ogness
2020-07-08 14:34   ` Petr Mladek
2020-07-08 14:34     ` Petr Mladek
2020-07-09  1:20   ` Sergey Senozhatsky
2020-07-09  1:20     ` Sergey Senozhatsky
2020-07-07 14:59 ` [PATCH v4 4/4] printk: use the lockless ringbuffer John Ogness
2020-07-07 14:59   ` John Ogness
2020-07-07 19:25   ` kernel test robot
2020-07-07 19:25     ` kernel test robot
2020-07-07 19:25     ` kernel test robot
2020-07-08 13:18     ` John Ogness
2020-07-08 13:18       ` John Ogness
2020-07-08 13:18       ` John Ogness
2020-07-08 14:35   ` Petr Mladek
2020-07-08 14:35     ` Petr Mladek
2020-07-08 19:24   ` kernel test robot
2020-07-08 19:24     ` kernel test robot
2020-07-08 19:24     ` kernel test robot
2020-07-09  7:14   ` [printk] 18a2dc6982: ltp.kmsg01.fail kernel test robot
2020-07-09  7:14     ` kernel test robot
2020-07-09  8:33     ` Sergey Senozhatsky
2020-07-09  8:33       ` Sergey Senozhatsky
2020-07-09 10:14       ` John Ogness
2020-07-09 10:14         ` John Ogness
2020-07-09 10:59         ` Petr Mladek
2020-07-09 10:59           ` Petr Mladek
2020-07-09 11:13           ` Petr Mladek
2020-07-09 11:13             ` Petr Mladek
2020-07-09 11:17             ` John Ogness
2020-07-09 11:17               ` John Ogness
2020-07-09 12:25               ` Petr Mladek
2020-07-09 12:25                 ` Petr Mladek
2020-07-09 13:07                 ` Sergey Senozhatsky
2020-07-09 13:07                   ` Sergey Senozhatsky
2020-07-09 14:41                   ` Petr Mladek
2020-07-09 14:41                     ` Petr Mladek
2020-07-08 15:20 ` [PATCH v4 0/4] printk: replace ringbuffer Petr Mladek
2020-07-08 15:20   ` Petr Mladek
2020-07-09  7:03   ` John Ogness
2020-07-09  7:03     ` John Ogness
2020-07-10  9:11     ` Petr Mladek
2020-07-10  9:11       ` Petr Mladek
2020-07-10  9:52       ` John Ogness
2020-07-10  9:52         ` John Ogness
2020-07-10 14:15         ` Petr Mladek
2020-07-10 14:15           ` Petr Mladek
2020-07-14  2:56         ` Sergey Senozhatsky
2020-07-14  2:56           ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707145932.8752-1-john.ogness@linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.