tracing/hwlat: Fix a race during cpuhp processing
authorWei Li <liwei391@huawei.com>
Tue, 24 Sep 2024 09:45:14 +0000 (17:45 +0800)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Thu, 3 Oct 2024 20:43:23 +0000 (16:43 -0400)
commit2a13ca2e8abb12ee43ada8a107dadca83f140937
tree46b1f2c0fe819db33b9bdee5f0f55ab3862a2d95
parent829e0c9f0855f26b3ae830d17b24aec103f7e915
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: ba998f7d9531 ("trace/hwlat: Support hotplug operations")
Signed-off-by: Wei Li <liwei391@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_hwlat.c