diff mbox series

[5.15-rt] printk: ignore that console preempted by irq/softirq.

Message ID 20240523235401355RFqSAGtIPwMKV39mUulN1@zte.com.cn
State Superseded
Headers show
Series [5.15-rt] printk: ignore that console preempted by irq/softirq. | expand

Commit Message

xu.xin16@zte.com.cn May 23, 2024, 3:54 p.m. UTC
From: xu xin <xu.xin16@zte.com.cn>

When we're in the unpreemptible context on the same cpu with which the
thread of console locates on, we should ignore this console for
pr_flush, because it's a vain and always lead to timeout  until the console
thread get cpu resource.

Fixes: e65be5f4dc3ed("printk: Update John Ogness' printk series")
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Cc: Zhang Yunkai <zhang.yunkai@zte.com.cn>
---
 kernel/printk/printk.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

xu xin May 23, 2024, 4:04 p.m. UTC | #1
Sorry, this is wrong subject. ignore this, it should have been to 5.10-rt
John Ogness May 26, 2024, 5:50 p.m. UTC | #2
On 2024-05-23, <xu.xin16@zte.com.cn> wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> When we're in the unpreemptible context on the same cpu with which the
> thread of console locates on, we should ignore this console for
> pr_flush, because it's a vain and always lead to timeout  until the console
> thread get cpu resource.
>
> Fixes: e65be5f4dc3ed("printk: Update John Ogness' printk series")
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> Cc: Zhang Yunkai <zhang.yunkai@zte.com.cn>

Reviewed-by: John Ogness <john.ogness@linutronix.de>
diff mbox series

Patch

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);