All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH printk v4 00/15] implement threaded console printing
@ 2022-04-21 21:22 John Ogness
  2022-04-21 21:22 ` [PATCH printk v4 01/15] printk: rename cpulock functions John Ogness
                   ` (15 more replies)
  0 siblings, 16 replies; 99+ messages in thread
From: John Ogness @ 2022-04-21 21:22 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner,
	linux-kernel, Andrew Morton, Randy Dunlap, Marco Elver,
	Stephen Boyd, Alexander Potapenko, Nicholas Piggin,
	Greg Kroah-Hartman, Jiri Slaby, Paul E. McKenney,
	Frederic Weisbecker, Neeraj Upadhyay, Josh Triplett,
	Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes, Kees Cook,
	Luis Chamberlain, Xiaoming Ni, Peter Zijlstra, Andy Shevchenko,
	Corey Minyard, Bjorn Andersson, Sebastian Andrzej Siewior,
	Mark Brown, Daniel Lezcano, Matti Vaittinen, Dmitry Torokhov,
	Eric W. Biederman, Shawn Guo, Wang Qing, rcu

This is v4 of a series to implement a kthread for each registered
console. v3 is here [0]. The kthreads locklessly retrieve the
records from the printk ringbuffer and also do not cause any lock
contention between each other. This allows consoles to run at full
speed. For example, a netconsole is able to dump records much
faster than a serial or vt console. Also, during normal operation,
printk() callers are completely decoupled from console printing.

There are situations where kthread printing is not sufficient. For
example, during panic situations, where the kthreads may not get a
chance to schedule. In such cases, the current method of attempting
to print directly within the printk() caller context is used. New
functions printk_prefer_direct_enter() and
printk_prefer_direct_exit() are made available to mark areas of the
kernel where direct printing is preferred. (These should only be
areas that do not occur during normal operation.)

This series also introduces pr_flush(): a might_sleep() function
that will block until all active printing threads have caught up
to the latest record at the time of the pr_flush() call. This
function is useful, for example, to wait until pending records
are flushed to consoles before suspending.

Note that this series does *not* increase the reliability of console
printing. Rather it focuses on the non-interference aspect of
printk() by decoupling printk() callers from printing (during normal
operation). Nonetheless, the reliability aspect should not worsen
due to this series.

John Ogness

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

Changes since v3:

- For defer_console_output(), call allow_direct_printing() instead
  of only checking @printk_prefer_direct.

- Remove console_lock_single_hold() and
  console_unlock_single_release() functions. Use the console_lock
  for console_stop(), console_start(), unregister_console(),
  printk_kthread_func().

- Introduce macros console_flags_set() and console_flags_clear() to
  adjust con->flags using READ_ONCE()/WRITE_ONCE() in order to
  guarantee consistent values for the variable. (This does not make
  the RMW operations atomic, but the console_lock and con->lock are
  still used to synchronize between tasks that modify con->flags.)

- Add and/or expand comments for allow_direct_printing(),
  console_cpu_notify(), __console_unlock(), console_stop(),
  console_start(), unregister_console(), printk_kthread_func(),
  defer_console_output().

John Ogness (15):
  printk: rename cpulock functions
  printk: cpu sync always disable interrupts
  printk: add missing memory barrier to wake_up_klogd()
  printk: wake up all waiters
  printk: wake waiters for safe and NMI contexts
  printk: get caller_id/timestamp after migration disable
  printk: call boot_delay_msec() in printk_delay()
  printk: add con_printk() macro for console details
  printk: refactor and rework printing logic
  printk: move buffer definitions into console_emit_next_record() caller
  printk: add pr_flush()
  printk: add functions to prefer direct printing
  printk: add kthread console printers
  printk: extend console_lock for proper kthread support
  printk: remove @console_locked

 drivers/tty/sysrq.c     |    2 +
 include/linux/console.h |   19 +
 include/linux/printk.h  |   82 ++-
 kernel/hung_task.c      |   11 +-
 kernel/panic.c          |    4 +
 kernel/printk/printk.c  | 1234 +++++++++++++++++++++++++++++----------
 kernel/rcu/tree_stall.h |    2 +
 kernel/reboot.c         |   14 +-
 kernel/watchdog.c       |    4 +
 kernel/watchdog_hld.c   |    4 +
 lib/dump_stack.c        |    4 +-
 lib/nmi_backtrace.c     |    4 +-
 12 files changed, 1059 insertions(+), 325 deletions(-)


base-commit: 84d7df104dbab9c3dda8f2c5b46f9a6fc256fe02
-- 
2.30.2


^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2022-06-23 10:11 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 21:22 [PATCH printk v4 00/15] implement threaded console printing John Ogness
2022-04-21 21:22 ` [PATCH printk v4 01/15] printk: rename cpulock functions John Ogness
2022-04-21 21:22 ` [PATCH printk v4 02/15] printk: cpu sync always disable interrupts John Ogness
2022-04-21 21:22 ` [PATCH printk v4 03/15] printk: add missing memory barrier to wake_up_klogd() John Ogness
2022-04-21 21:22 ` [PATCH printk v4 04/15] printk: wake up all waiters John Ogness
2022-04-21 21:22 ` [PATCH printk v4 05/15] printk: wake waiters for safe and NMI contexts John Ogness
2022-04-21 21:22 ` [PATCH printk v4 06/15] printk: get caller_id/timestamp after migration disable John Ogness
2022-04-21 21:22 ` [PATCH printk v4 07/15] printk: call boot_delay_msec() in printk_delay() John Ogness
2022-04-21 21:22 ` [PATCH printk v4 08/15] printk: add con_printk() macro for console details John Ogness
2022-04-21 21:22 ` [PATCH printk v4 09/15] printk: refactor and rework printing logic John Ogness
2022-04-21 21:22 ` [PATCH printk v4 10/15] printk: move buffer definitions into console_emit_next_record() caller John Ogness
2022-04-21 21:22 ` [PATCH printk v4 11/15] printk: add pr_flush() John Ogness
2022-04-21 21:22 ` [PATCH printk v4 12/15] printk: add functions to prefer direct printing John Ogness
2022-04-21 21:22 ` [PATCH printk v4 13/15] printk: add kthread console printers John Ogness
2022-04-22  7:48   ` Petr Mladek
2022-04-21 21:22 ` [PATCH printk v4 14/15] printk: extend console_lock for proper kthread support John Ogness
2022-04-21 21:40   ` John Ogness
2022-04-22  9:21   ` Petr Mladek
2022-04-25 20:58   ` [PATCH printk v5 1/1] printk: extend console_lock for per-console locking John Ogness
2022-04-26 12:07     ` Petr Mladek
2022-04-26 13:16       ` Petr Mladek
     [not found]         ` <CGME20220427070833eucas1p27a32ce7c41c0da26f05bd52155f0031c@eucas1p2.samsung.com>
2022-04-27  7:08           ` Marek Szyprowski
2022-04-27  7:08             ` Marek Szyprowski
2022-04-27  7:38             ` Petr Mladek
2022-04-27  7:38               ` Petr Mladek
2022-04-27 11:44               ` Marek Szyprowski
2022-04-27 11:44                 ` Marek Szyprowski
2022-04-27 16:15                 ` John Ogness
2022-04-27 16:15                   ` John Ogness
2022-04-27 16:48                   ` Petr Mladek
2022-04-27 16:48                     ` Petr Mladek
2022-04-28 14:54                   ` Petr Mladek
2022-04-28 14:54                     ` Petr Mladek
2022-04-29 13:53                   ` Marek Szyprowski
2022-04-29 13:53                     ` Marek Szyprowski
2022-04-30 16:00                     ` John Ogness
2022-04-30 16:00                       ` John Ogness
2022-05-02  9:19                       ` Marek Szyprowski
2022-05-02  9:19                         ` Marek Szyprowski
2022-05-02 13:11                         ` John Ogness
2022-05-02 13:11                           ` John Ogness
2022-05-02 22:29                           ` Marek Szyprowski
2022-05-02 22:29                             ` Marek Szyprowski
2022-05-04  5:56                             ` John Ogness
2022-05-04  5:56                               ` John Ogness
2022-05-04  6:52                               ` Marek Szyprowski
2022-05-04  6:52                                 ` Marek Szyprowski
2022-06-08 15:10                           ` Geert Uytterhoeven
2022-06-08 15:10                             ` Geert Uytterhoeven
2022-06-09 11:19                             ` John Ogness
2022-06-09 11:19                               ` John Ogness
2022-06-09 11:58                               ` Jason A. Donenfeld
2022-06-09 11:58                                 ` Jason A. Donenfeld
2022-06-09 12:18                                 ` Dmitry Vyukov
2022-06-09 12:18                                   ` Dmitry Vyukov
2022-06-09 12:27                                   ` Jason A. Donenfeld
2022-06-09 12:27                                     ` Jason A. Donenfeld
2022-06-09 12:32                                     ` Dmitry Vyukov
2022-06-09 12:32                                       ` Dmitry Vyukov
2022-06-17 16:51                                     ` Sebastian Andrzej Siewior
2022-06-17 16:51                                       ` Sebastian Andrzej Siewior
2022-06-09 12:18                                 ` Jason A. Donenfeld
2022-06-09 12:18                                   ` Jason A. Donenfeld
2022-05-02 13:17                         ` Petr Mladek
2022-05-02 13:17                           ` Petr Mladek
2022-05-02 23:13                           ` Marek Szyprowski
2022-05-02 23:13                             ` Marek Szyprowski
2022-05-03  6:49                             ` Petr Mladek
2022-05-03  6:49                               ` Petr Mladek
2022-05-04  6:05                               ` Marek Szyprowski
2022-05-04  6:05                                 ` Marek Szyprowski
2022-05-04 21:11                             ` John Ogness
2022-05-04 21:11                               ` John Ogness
2022-05-04 22:42                               ` John Ogness
2022-05-04 22:42                                 ` John Ogness
2022-05-05 22:33                                 ` John Ogness
2022-05-05 22:33                                   ` John Ogness
2022-05-06  6:43                                   ` Marek Szyprowski
2022-05-06  6:43                                     ` Marek Szyprowski
2022-05-06  7:55                                     ` Neil Armstrong
2022-05-06  7:55                                       ` Neil Armstrong
2022-05-08 11:02                                       ` John Ogness
2022-05-08 11:02                                         ` John Ogness
2022-05-06  8:16                                     ` Petr Mladek
2022-05-06  8:16                                       ` Petr Mladek
2022-05-06  9:20                                     ` John Ogness
2022-05-06  9:20                                       ` John Ogness
     [not found]             ` <CGME20220506112526eucas1p2a3688f87d3ed8331b99f2f876bf6c2f6@eucas1p2.samsung.com>
2022-05-06 11:25               ` Marek Szyprowski
2022-05-06 12:41                 ` John Ogness
2022-05-06 13:04                   ` Marek Szyprowski
2022-06-22  9:03     ` Geert Uytterhoeven
2022-06-22  9:03       ` Geert Uytterhoeven
2022-06-22 22:37       ` John Ogness
2022-06-22 22:37         ` John Ogness
2022-06-23 10:10         ` Geert Uytterhoeven
2022-06-23 10:10           ` Geert Uytterhoeven
2022-04-21 21:22 ` [PATCH printk v4 15/15] printk: remove @console_locked John Ogness
2022-04-22  9:39 ` [PATCH printk v4 00/15] implement threaded console printing Petr Mladek
2022-04-22 20:29   ` Petr Mladek

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.