From 294835cc45ca8c9d66a95adb23d2c3de51c08655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=82=A3=E5=87=A0?= <2078634206@qq.com> Date: Fri, 21 Aug 2026 08:31:41 +0800 Subject: [PATCH] tkernel: irqlatency: hold the cpu lock when removing the hotplug state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cpuhp_remove_state() requires the caller to hold the cpu read lock: its internals assert cpus_held() and may wait for the hotplug threads that run the teardown callbacks which stop the per-cpu timers. The enable_write() and trace_stack_write() control paths already take cpus_read_lock() around their hotplug operations, but the module exit path does not, so unloading the module on a lockdep kernel triggers the assertion in __cpuhp_remove_state_cpuslocked(). Take the cpu read lock around cpuhp_remove_state() in trace_latency_exit(), matching the locking used by the other control paths in the same file. Upstream status: downstream-only Signed-off-by: 陈那几 <2078634206@qq.com> --- kernel/tkernel/irqlatency/irqlatency.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/tkernel/irqlatency/irqlatency.c b/kernel/tkernel/irqlatency/irqlatency.c index dc7f89b7c6bd..f4ea48a78536 100644 --- a/kernel/tkernel/irqlatency/irqlatency.c +++ b/kernel/tkernel/irqlatency/irqlatency.c @@ -753,8 +753,10 @@ static void __exit trace_latency_exit(void) { remove_proc_subtree("irq_latency", NULL); mutex_lock(&control_lock); + cpus_read_lock(); WRITE_ONCE(check_enable, 0); cpuhp_remove_state(irqlatency_hp_state); + cpus_read_unlock(); mutex_unlock(&control_lock); free_percpu(detect_data); pr_info("Unload irq latency check module!\n"); -- Gitee