All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next v3 0/2] introduce printk cpu lock
@ 2021-06-15 17:49 John Ogness
  2021-06-15 17:49 ` [PATCH next v3 1/2] dump_stack: move cpu lock to printk.c John Ogness
  2021-06-15 17:49 ` [PATCH next v3 2/2] printk: fix cpu lock ordering John Ogness
  0 siblings, 2 replies; 10+ messages in thread
From: John Ogness @ 2021-06-15 17:49 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, Thomas Gleixner,
	linux-kernel, Stephen Rothwell, Andrew Morton,
	Daniel Bristot de Oliveira, Stephen Boyd, Alexander Potapenko,
	Peter Zijlstra, 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).

This series is against next-20210615.

v2 can be found here [1].

Changes since v2:

- Remove @lock_flag argument from lock/unlock functions. Since there
  is only 1 global printk cpu lock, the @lock_flag can be a static
  global variable inside printk.c. Also, that flag is renamed to
  @printk_cpulock_nested.

- Use typical irqsave/irqrestore calling conventions. This means
  changing the lock/unlock functions to macros and set the irq flags
  within those macros, rather than passing the irq flags as a
  function argument.

- Split the lock function into 2 functions: trylock and wait. This
  simplifies the macro implementation. Later, for atomic consoles,
  this will be useful because atomic consoles will implement the
  waiting component differently.

- Fix a "used uninitialized" warning for !CONFIG_SMP, reported by
  the kbuild robot.

- Extend memory barrier comments to cover both "previous to current"
  and "current to next" guarantees.

John Ogness

[0] https://lore.kernel.org/lkml/YGW63%2FelFr%2FgYW1u@alley
[1] https://lore.kernel.org/lkml/20210607200232.22211-1-john.ogness@linutronix.de

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

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

--
2.20.1


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

end of thread, other threads:[~2021-06-16 13:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 17:49 [PATCH next v3 0/2] introduce printk cpu lock John Ogness
2021-06-15 17:49 ` [PATCH next v3 1/2] dump_stack: move cpu lock to printk.c John Ogness
2021-06-15 21:33   ` John Ogness
2021-06-16  7:06     ` Sergey Senozhatsky
2021-06-16  7:29       ` John Ogness
2021-06-16 11:21         ` Petr Mladek
2021-06-16 13:40           ` John Ogness
2021-06-16 11:55         ` Sergey Senozhatsky
2021-06-15 17:49 ` [PATCH next v3 2/2] printk: fix cpu lock ordering John Ogness
2021-06-16 11:30   ` 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.