Commit 0e1d5731 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Petr Mladek

printk: Check printk_deferred_enter()/_exit() usage

Add validation that printk_deferred_enter()/_exit() are called in
non-migration contexts.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20240820063001.36405-5-john.ogness@linutronix.deSigned-off-by: default avatarPetr Mladek <pmladek@suse.com>
parent d3ff380d
...@@ -161,15 +161,16 @@ int _printk(const char *fmt, ...); ...@@ -161,15 +161,16 @@ int _printk(const char *fmt, ...);
*/ */
__printf(1, 2) __cold int _printk_deferred(const char *fmt, ...); __printf(1, 2) __cold int _printk_deferred(const char *fmt, ...);
extern void __printk_safe_enter(void); extern void __printk_deferred_enter(void);
extern void __printk_safe_exit(void); extern void __printk_deferred_exit(void);
/* /*
* The printk_deferred_enter/exit macros are available only as a hack for * 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 * some code paths that need to defer all printk console printing. Interrupts
* must be disabled for the deferred duration. * must be disabled for the deferred duration.
*/ */
#define printk_deferred_enter __printk_safe_enter #define printk_deferred_enter() __printk_deferred_enter()
#define printk_deferred_exit __printk_safe_exit #define printk_deferred_exit() __printk_deferred_exit()
/* /*
* Please don't use printk_ratelimit(), because it shares ratelimiting state * Please don't use printk_ratelimit(), because it shares ratelimiting state
......
...@@ -53,6 +53,9 @@ int vprintk_store(int facility, int level, ...@@ -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_default(const char *fmt, va_list args);
__printf(1, 0) int vprintk_deferred(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); bool printk_percpu_data_ready(void);
#define printk_safe_enter_irqsave(flags) \ #define printk_safe_enter_irqsave(flags) \
......
...@@ -26,6 +26,18 @@ void __printk_safe_exit(void) ...@@ -26,6 +26,18 @@ void __printk_safe_exit(void)
this_cpu_dec(printk_context); 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) asmlinkage int vprintk(const char *fmt, va_list args)
{ {
#ifdef CONFIG_KGDB_KDB #ifdef CONFIG_KGDB_KDB
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment