From: Stephen Brennan <stephen.s.brennan@oracle.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
John Ogness <john.ogness@linutronix.de>,
Stephen Brennan <stephen.s.brennan@oracle.com>
Subject: [PATCH v3 1/4] printk: Add panic_in_progress helper
Date: Tue, 1 Feb 2022 10:57:59 -0800 [thread overview]
Message-ID: <20220201185802.98345-2-stephen.s.brennan@oracle.com> (raw)
In-Reply-To: <20220201185802.98345-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. 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>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
Notes:
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..b33c2861a8fc 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1762,6 +1762,11 @@ static DEFINE_RAW_SPINLOCK(console_owner_lock);
static struct task_struct *console_owner;
static bool console_waiter;
+static bool panic_in_progress(void)
+{
+ return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID);
+}
+
/**
* console_lock_spinning_enable - mark beginning of code where another
* thread might safely busy wait
--
2.30.2
next prev parent reply other threads:[~2022-02-01 18:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 18:57 [PATCH v3 0/4] printk: reduce deadlocks during panic Stephen Brennan
2022-02-01 18:57 ` Stephen Brennan [this message]
2022-02-02 1:39 ` [PATCH v3 1/4] printk: Add panic_in_progress helper Stephen Brennan
2022-02-01 18:58 ` [PATCH v3 2/4] printk: disable optimistic spin during panic Stephen Brennan
2022-02-01 18:58 ` [PATCH v3 3/4] printk: Avoid livelock with heavy printk " Stephen Brennan
2022-02-01 18:58 ` [PATCH v3 4/4] printk: Drop console_sem " Stephen Brennan
2022-02-04 4:04 ` Sergey Senozhatsky
2022-02-04 18:53 ` Stephen Brennan
2022-02-08 2:15 ` 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=20220201185802.98345-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®