[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240222090538.23017-1-quic_mojha@quicinc.com>
Date: Thu, 22 Feb 2024 14:35:38 +0530
From: Mukesh Ojha <quic_mojha@...cinc.com>
To: <pmladek@...e.com>, <rostedt@...dmis.org>, <john.ogness@...utronix.de>,
<senozhatsky@...omium.org>
CC: <linux-kernel@...r.kernel.org>, Mukesh Ojha <quic_mojha@...cinc.com>
Subject: [PATCH] printk: Add atomic context check inside console_unlock()
Situation of schedule while atomic context can happen in a
scenario if CPU-Y executing a async probe of ufs and while
printing a line it is started spinning for console lock
after preemption disable on CPU-Y and later it got the handover
of console lock from CPU-X and in console_unlock() it get
schedule with preempt disable as console_may_schedule was one
and due to which do_cond_resched was one.
CPU-X CPU-Y
worker_thread
process_one_work
async_run_entry_fn
ufshcd_async_scan
ufshcd_device_init
really_probe+0x1c8 ufshcd_probe_hba
platform_probe+0xc0 ufshcd_config_mcq
qcom_geni_serial_probe+0x374 _dev_info
uart_add_one_port+0x10 __dev_printk
serial_ctrl_register_port+0x10 dev_printk_emit
serial_core_register_port+0x5dc dev_vprintk_emit
register_console+0x284 vprintk_emit
console_init_seq() preempt_disable();
console_trylock_spinning()
console_lock();
console_flush_all()
Hand over of console lock happen from CPU-X to CPU-Y
console_unlock()
console_lock+0x74 console_flush_all
down[jt]+0x40 __might_resched
__down+0x18
__down_common+0x68
___down_common+0xdc
schedule_timeout+0x4c
schedule+0x78
__schedule+0x6c0
Signed-off-by: Mukesh Ojha <quic_mojha@...cinc.com>
---
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 f2444b581e16..8b666feff65d 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3028,7 +3028,7 @@ void console_unlock(void)
* messages practically incapacitating the system. Therefore, create
* a local to use for the printing loop.
*/
- do_cond_resched = console_may_schedule;
+ do_cond_resched = in_atomic() || console_may_schedule;
do {
console_may_schedule = 0;
--
2.43.0.254.ga26002b62827
Powered by blists - more mailing lists