mirror of https://lore.kernel.org/lkml/
 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,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH printk v6 04/30] printk: Check printk_deferred_enter()/_exit() usage
Date: Mon, 27 May 2024 08:43:23 +0206	[thread overview]
Message-ID: <20240527063749.391035-5-john.ogness@linutronix.de> (raw)
In-Reply-To: <20240527063749.391035-1-john.ogness@linutronix.de>

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Add validation that printk_deferred_enter()/_exit() are called in
non-migration contexts.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
---
 include/linux/printk.h      |  9 +++++----
 kernel/printk/internal.h    |  3 +++
 kernel/printk/printk_safe.c | 12 ++++++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index dbbd202b1cb3..6e1f055afef6 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -157,15 +157,16 @@ int _printk(const char *fmt, ...);
  */
 __printf(1, 2) __cold int _printk_deferred(const char *fmt, ...);
 
-extern void __printk_safe_enter(void);
-extern void __printk_safe_exit(void);
+extern void __printk_deferred_enter(void);
+extern void __printk_deferred_exit(void);
+
 /*
  * The printk_deferred_enter/exit macros are available only as a hack for
  * some code paths that need to defer all printk console printing. Interrupts
  * must be disabled for the deferred duration.
  */
-#define printk_deferred_enter __printk_safe_enter
-#define printk_deferred_exit __printk_safe_exit
+#define printk_deferred_enter() __printk_deferred_enter()
+#define printk_deferred_exit() __printk_deferred_exit()
 
 /*
  * Please don't use printk_ratelimit(), because it shares ratelimiting state
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 739b82adc383..831f95f26d48 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -53,6 +53,9 @@ int vprintk_store(int facility, int level,
 __printf(1, 0) int vprintk_default(const char *fmt, va_list args);
 __printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
 
+void __printk_safe_enter(void);
+void __printk_safe_exit(void);
+
 bool printk_percpu_data_ready(void);
 
 #define printk_safe_enter_irqsave(flags)	\
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 6d10927a07d8..4421ccac3113 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -26,6 +26,18 @@ void __printk_safe_exit(void)
 	this_cpu_dec(printk_context);
 }
 
+void __printk_deferred_enter(void)
+{
+	cant_migrate();
+	__printk_safe_enter();
+}
+
+void __printk_deferred_exit(void)
+{
+	cant_migrate();
+	__printk_safe_exit();
+}
+
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
 #ifdef CONFIG_KGDB_KDB
-- 
2.39.2


  parent reply	other threads:[~2024-05-27  6:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27  6:37 [PATCH printk v6 00/30] wire up write_atomic() printing John Ogness
2024-05-27  6:37 ` [PATCH printk v6 01/30] printk: Add notation to console_srcu locking John Ogness
2024-05-27  6:37 ` [PATCH printk v6 02/30] printk: Properly deal with nbcon consoles on seq init John Ogness
2024-05-27  6:37 ` [PATCH printk v6 03/30] printk: nbcon: Remove return value for write_atomic() John Ogness
2024-05-27  6:37 ` John Ogness [this message]
2024-05-27  6:37 ` [PATCH printk v6 05/30] printk: nbcon: Add detailed doc " John Ogness
2024-05-27  6:37 ` [PATCH printk v6 06/30] printk: nbcon: Add callbacks to synchronize with driver John Ogness
2024-05-27  6:37 ` [PATCH printk v6 07/30] printk: nbcon: Use driver synchronization while (un)registering John Ogness
2024-05-27  6:37 ` [PATCH printk v6 08/30] serial: core: Provide low-level functions to lock port John Ogness
2024-05-27  6:37 ` [PATCH printk v6 09/30] serial: core: Introduce wrapper to set @uart_port->cons John Ogness
2024-05-27  6:37 ` [PATCH printk v6 10/30] console: Improve console_srcu_read_flags() comments John Ogness
2024-05-27  6:37 ` [PATCH printk v6 11/30] nbcon: Add API to acquire context for non-printing operations John Ogness
2024-05-27  6:37 ` [PATCH printk v6 12/30] serial: core: Implement processing in port->lock wrapper John Ogness
2024-05-27  6:37 ` [PATCH printk v6 13/30] printk: nbcon: Do not rely on proxy headers John Ogness
2024-05-27  6:37 ` [PATCH printk v6 14/30] printk: nbcon: Fix kerneldoc for enums John Ogness
2024-05-27  6:37 ` [PATCH printk v6 15/30] printk: Make console_is_usable() available to nbcon John Ogness
2024-05-27  6:37 ` [PATCH printk v6 16/30] printk: Let console_is_usable() handle nbcon John Ogness
2024-05-27  6:37 ` [PATCH printk v6 17/30] printk: Add @flags argument for console_is_usable() John Ogness
2024-05-27  6:37 ` [PATCH printk v6 18/30] printk: nbcon: Add helper to assign priority based on CPU state John Ogness
2024-05-27  6:37 ` [PATCH printk v6 19/30] printk: nbcon: Provide function to flush using write_atomic() John Ogness
2024-05-28  9:30   ` Petr Mladek
2024-05-27  6:37 ` [PATCH printk v6 20/30] printk: Track registered boot consoles John Ogness
2024-05-27  6:37 ` [PATCH printk v6 21/30] printk: nbcon: Use nbcon consoles in console_flush_all() John Ogness
2024-05-27  6:37 ` [PATCH printk v6 22/30] printk: nbcon: Add unsafe flushing on panic John Ogness
2024-05-27  6:37 ` [PATCH printk v6 23/30] printk: Avoid console_lock dance if no legacy or boot consoles John Ogness
2024-05-27  6:37 ` [PATCH printk v6 24/30] printk: Track nbcon consoles John Ogness
2024-05-27  6:37 ` [PATCH printk v6 25/30] printk: Coordinate direct printing in panic John Ogness
2024-05-27  6:37 ` [PATCH printk v6 26/30] printk: nbcon: Implement emergency sections John Ogness
2024-05-28  9:57   ` Petr Mladek
2024-05-27  6:37 ` [PATCH printk v6 27/30] panic: Mark emergency section in warn John Ogness
2024-05-27  6:37 ` [PATCH printk v6 28/30] panic: Mark emergency section in oops John Ogness
2024-05-27  6:37 ` [PATCH printk v6 29/30] rcu: Mark emergency sections in rcu stalls John Ogness
2024-05-28 10:04   ` Petr Mladek
2024-05-27  6:37 ` [PATCH printk v6 30/30] lockdep: Mark emergency sections in lockdep splats John Ogness
2024-05-28 10:10 ` [PATCH printk v6 00/30] wire up write_atomic() printing Petr Mladek
2024-05-28 13:35   ` 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=20240527063749.391035-5-john.ogness@linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=bigeasy@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 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®