Commit 2a13ca2e authored by Wei Li's avatar Wei Li Committed by Steven Rostedt (Google)

tracing/hwlat: Fix a race during cpuhp processing

The cpuhp online/offline processing race also exists in percpu-mode hwlat
tracer in theory, apply the fix too. That is:

    T1                       | T2
    [CPUHP_ONLINE]           | cpu_device_down()
     hwlat_hotplug_workfn()  |
                             |     cpus_write_lock()
                             |     takedown_cpu(1)
                             |     cpus_write_unlock()
    [CPUHP_OFFLINE]          |
        cpus_read_lock()     |
        start_kthread(1)     |
        cpus_read_unlock()   |

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20240924094515.3561410-5-liwei391@huawei.com
Fixes: ba998f7d ("trace/hwlat: Support hotplug operations")
Signed-off-by: default avatarWei Li <liwei391@huawei.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 829e0c9f
...@@ -520,6 +520,8 @@ static void hwlat_hotplug_workfn(struct work_struct *dummy) ...@@ -520,6 +520,8 @@ static void hwlat_hotplug_workfn(struct work_struct *dummy)
if (!hwlat_busy || hwlat_data.thread_mode != MODE_PER_CPU) if (!hwlat_busy || hwlat_data.thread_mode != MODE_PER_CPU)
goto out_unlock; goto out_unlock;
if (!cpu_online(cpu))
goto out_unlock;
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask)) if (!cpumask_test_cpu(cpu, tr->tracing_cpumask))
goto out_unlock; goto out_unlock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment