All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Petr Mladek <pmladek@suse.com>
Cc: linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Stephen Brennan <stephen.s.brennan@oracle.com>
Subject: [PATCH v4 1/4] printk: Add panic_in_progress helper
Date: Wed,  2 Feb 2022 09:18:18 -0800	[thread overview]
Message-ID: <20220202171821.179394-2-stephen.s.brennan@oracle.com> (raw)
In-Reply-To: <20220202171821.179394-1-stephen.s.brennan@oracle.com>

This will be used help avoid deadlocks during panics. Although it would
be better to include this in linux/panic.h, it would require that header
to include linux/atomic.h as well. On some architectures, this results
in a circular dependency as well. So instead add the helper directly to
printk.c.

Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---

Notes:
    v4: Move helper outside CONFIG_PRINTK section
    v3: Move the helper into printk.c due to circular include
    v2: Switch from macro to static inline function

 kernel/printk/printk.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 57b132b658e1..e3d986dd49a1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -256,6 +256,11 @@ static void __up_console_sem(unsigned long ip)
 }
 #define up_console_sem() __up_console_sem(_RET_IP_)
 
+static bool panic_in_progress(void)
+{
+	return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID);
+}
+
 /*
  * This is used for debugging the mess that is the VT code by
  * keeping track if we have the console semaphore held. It's
-- 
2.30.2


  reply	other threads:[~2022-02-02 17:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 17:18 [PATCH v4 0/4] printk: reduce deadlocks during panic Stephen Brennan
2022-02-02 17:18 ` Stephen Brennan [this message]
2022-02-02 17:18 ` [PATCH v4 2/4] printk: disable optimistic spin " Stephen Brennan
2022-02-02 17:18 ` [PATCH v4 3/4] printk: Avoid livelock with heavy printk " Stephen Brennan
2022-02-02 17:18 ` [PATCH v4 4/4] printk: Drop console_sem " Stephen Brennan
2022-02-10  9:22 ` [PATCH v4 0/4] printk: reduce deadlocks " Petr Mladek
2022-02-10 20:06   ` Stephen Brennan
2022-02-14 13:54     ` Petr Mladek
2022-02-15 23:24       ` Stephen Brennan
2022-02-14  2:27   ` 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=20220202171821.179394-2-stephen.s.brennan@oracle.com \
    --to=stephen.s.brennan@oracle.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.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.