Message ID | 20240523235537910_yxfGMbTcSOmMkcfuK2d8@zte.com.cn |
---|---|
State | New |
Headers | show |
Series | [5.10-rt] printk: ignore that console preempted by irq/softirq | expand |
On 2024-05-28, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> There is a `may_sleep` variable set earlier. Couldn't that be re-used?
Since the printing thread cannot preempt the softirq context and since
the printing threads are not started before @system_state is
SYSTEM_RUNNING, using @may_sleep is OK.
if (!may_sleep &&
con->thread &&
task_cpu(con->thread) == smp_processor_id()) {
continue;
}
John Ogness
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7f27cfee283e..faab85dd4439 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3735,6 +3735,14 @@ bool pr_flush(int timeout_ms, bool reset_on_progress) diff = 0; for_each_console(con) { + /* + * When we're in the unpreemptible context on the same cpu + * with which the thread of console locates on, we should + * ignore this console, because it's a vain. + */ + if (!preemptible() && con->thread && + task_cpu(con->thread) == smp_processor_id()) + continue; if (!(con->flags & CON_ENABLED)) continue; printk_seq = read_console_seq(con);