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
Subject: [PATCH printk v2 2/4] printk: Add this_cpu_in_panic()
Date: Fri, 13 Oct 2023 22:49:38 +0206 [thread overview]
Message-ID: <20231013204340.1112036-3-john.ogness@linutronix.de> (raw)
In-Reply-To: <20231013204340.1112036-1-john.ogness@linutronix.de>
There is already panic_in_progress() and other_cpu_in_panic(),
but checking if the current CPU is the panic CPU must still be
open coded.
Add this_cpu_in_panic() to complete the set.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/internal.h | 1 +
kernel/printk/printk.c | 43 +++++++++++++++++++++-------------------
2 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 7d4979d5c3ce..2397734c0fd2 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -105,3 +105,4 @@ struct printk_message {
};
bool other_cpu_in_panic(void);
+bool this_cpu_in_panic(void);
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index abb6a50ee26f..19b752880879 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -351,6 +351,29 @@ static bool panic_in_progress(void)
return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID);
}
+/* Return true if a panic is in progress on the current CPU. */
+bool this_cpu_in_panic(void)
+{
+ /*
+ * We can use raw_smp_processor_id() here because it is impossible for
+ * the task to be migrated to the panic_cpu, or away from it. If
+ * panic_cpu has already been set, and we're not currently executing on
+ * that CPU, then we never will be.
+ */
+ return unlikely(atomic_read(&panic_cpu) == raw_smp_processor_id());
+}
+
+/*
+ * Return true if a panic is in progress on a remote CPU.
+ *
+ * On true, the local CPU should immediately release any printing resources
+ * that may be needed by the panic CPU.
+ */
+bool other_cpu_in_panic(void)
+{
+ return (panic_in_progress() && !this_cpu_in_panic());
+}
+
/*
* This is used for debugging the mess that is the VT code by
* keeping track if we have the console semaphore held. It's
@@ -2610,26 +2633,6 @@ static int console_cpu_notify(unsigned int cpu)
return 0;
}
-/*
- * Return true if a panic is in progress on a remote CPU.
- *
- * On true, the local CPU should immediately release any printing resources
- * that may be needed by the panic CPU.
- */
-bool other_cpu_in_panic(void)
-{
- if (!panic_in_progress())
- return false;
-
- /*
- * We can use raw_smp_processor_id() here because it is impossible for
- * the task to be migrated to the panic_cpu, or away from it. If
- * panic_cpu has already been set, and we're not currently executing on
- * that CPU, then we never will be.
- */
- return atomic_read(&panic_cpu) != raw_smp_processor_id();
-}
-
/**
* console_lock - block the console subsystem from printing
*
--
2.39.2
next prev parent reply other threads:[~2023-10-13 20:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 20:43 [PATCH printk v2 0/4] fix console flushing on panic John Ogness
2023-10-13 20:43 ` [PATCH printk v2 1/4] printk: For @suppress_panic_printk check other panic John Ogness
2023-10-16 13:05 ` Petr Mladek
2023-10-13 20:43 ` John Ogness [this message]
2023-10-16 13:14 ` [PATCH printk v2 2/4] printk: Add this_cpu_in_panic() Petr Mladek
2023-10-13 20:43 ` [PATCH printk v2 3/4] printk: Skip unfinalized records in panic John Ogness
2023-10-17 11:27 ` Petr Mladek
2023-10-17 21:25 ` John Ogness
2023-10-18 8:24 ` John Ogness
2023-10-18 13:15 ` Petr Mladek
2023-10-18 12:54 ` Petr Mladek
2023-10-18 13:45 ` John Ogness
2023-10-18 15:27 ` Petr Mladek
2023-10-18 15:50 ` John Ogness
2023-10-19 10:29 ` Petr Mladek
2023-10-18 14:20 ` Petr Mladek
2023-10-23 9:53 ` John Ogness
2023-10-13 20:43 ` [PATCH printk v2 4/4] printk: Ignore waiter on panic John Ogness
2023-10-18 9:56 ` Petr Mladek
2023-10-23 9:15 ` John Ogness
2023-10-13 20:46 ` [PATCH printk v2 0/4] fix console flushing " John Ogness
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=20231013204340.1112036-3-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@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.