[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bkzj3t77.fsf@jogness.linutronix.de>
Date: Mon, 07 Feb 2022 10:52:20 +0106
From: John Ogness <john.ogness@...utronix.de>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
linux-kernel@...r.kernel.org,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [PATCH v2] printk: defer_console_output: use atomic update
The per-cpu @printk_pending variable can be updated from
sleepable contexts, such as:
get_random_bytes()
warn_unseeded_randomness()
printk_deferred()
defer_console_output()
and can be updated from interrupt contexts, such as:
handle_irq_event_percpu()
__irq_wake_thread()
wake_up_process()
try_to_wake_up()
select_task_rq()
select_fallback_rq()
printk_deferred()
defer_console_output()
and can be updated from NMI contexts, such as:
vprintk()
if (in_nmi()) defer_console_output()
Therefore this_cpu_or(), the atomic variant of __this_cpu_or(),
should be used to update the variable.
Reported-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Reviewed-by: Sergey Senozhatsky <senozhatsky@...omium.org>
Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
Change from v1:
Sebastian comments made it clear that the v1 title and message were not
correctly specifying the problem or the reason for the fix. I hope this
text is clearer.
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 82abfaf3c2aa..164ccdb9423e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3262,7 +3262,7 @@ void defer_console_output(void)
return;
preempt_disable();
- __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+ this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
preempt_enable();
}
base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566
--
2.30.2
Powered by blists - more mailing lists