linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next v4 0/2] introduce printk cpu lock
@ 2021-06-17  9:50 John Ogness
  2021-06-17  9:50 ` [PATCH next v4 1/2] lib/dump_stack: move cpu lock to printk.c John Ogness
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: John Ogness @ 2021-06-17  9:50 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner,
	linux-kernel, Stephen Rothwell, Andrew Morton, Peter Zijlstra,
	Daniel Bristot de Oliveira, Stephen Boyd, Alexander Potapenko,
	Paul E. McKenney

Hello,

While working on removing the safe buffers for printk [0] we
stumbled on a cpu-reentrant spinning lock used by dump_stack(). This
type of lock (dubbed a cpu lock) will cause deadlock risks once we
introduce atomic consoles because atomic consoles also need such a
lock.

Although we are not yet ready to introduce atomic consoles, this is
an appropriate time to provide an official cpu lock to be used for
all things relating to printk (including the atomic consoles, once
they are introduced).

An example of cpu lock usage for atomic consoles can be found in the
PREEMPT_RT tree, such as the serial8250 implementation [1] of an
atomic console. (In PREEMPT_RT the printk cpu lock function was
named console_atomic_lock/_unlock.)

This series is against next-20210616.

v3 can be found here [2].

Changes since v3:

- Change @printk_cpulock_nested from a boolean to an atomic counter
  in order to track multiple levels of nesting.

- Correctly move over the original dump_stack() semantics by using
  atomic_set() to unlock.

- Move commit message note about disabling interrupts to the first
  patch.

John Ogness

[0] https://lore.kernel.org/lkml/YGW63%2FelFr%2FgYW1u@alley
[1] https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/drivers/tty/serial?h=v5.12-rc3-rt3&id=1aaca59df62710647243a3574fc27d93c2bd0e6c
[2] https://lore.kernel.org/lkml/20210615174947.32057-1-john.ogness@linutronix.de

John Ogness (2):
  lib/dump_stack: move cpu lock to printk.c
  printk: fix cpu lock ordering

 include/linux/printk.h |  41 +++++++++++++++
 kernel/printk/printk.c | 116 +++++++++++++++++++++++++++++++++++++++++
 lib/dump_stack.c       |  38 +-------------
 3 files changed, 159 insertions(+), 36 deletions(-)

-- 
2.20.1


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

end of thread, other threads:[~2021-06-19  0:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17  9:50 [PATCH next v4 0/2] introduce printk cpu lock John Ogness
2021-06-17  9:50 ` [PATCH next v4 1/2] lib/dump_stack: move cpu lock to printk.c John Ogness
2021-06-17 13:32   ` Steven Rostedt
2021-06-18 14:47     ` Petr Mladek
2021-06-18 16:25       ` Steven Rostedt
2021-06-19  0:22         ` John Ogness
2021-06-18 14:55     ` John Ogness
2021-06-18 16:31       ` Steven Rostedt
2021-06-17  9:50 ` [PATCH next v4 2/2] printk: fix cpu lock ordering John Ogness
2021-06-17 11:23 ` [PATCH next v4 0/2] introduce printk cpu lock Petr Mladek
2021-06-17 11:28   ` Stephen Rothwell
2021-06-17 11:39 ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).