All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Alexander Potapenko <glider@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH next v3 0/2] introduce printk cpu lock
Date: Tue, 15 Jun 2021 19:55:45 +0206	[thread overview]
Message-ID: <20210615174947.32057-1-john.ogness@linutronix.de> (raw)

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


             reply	other threads:[~2021-06-15 17:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 17:49 John Ogness [this message]
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

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=20210615174947.32057-1-john.ogness@linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=bristot@redhat.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfr@canb.auug.org.au \
    --cc=swboyd@chromium.org \
    --cc=tglx@linutronix.de \
    /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.