Message ID | 20230310100451.3948583-3-tero.kristo@linux.intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 08697bca9bbba15f2058fdbd9f970bd5f6a8a2e8 |
Headers | show |
Series | trace/hwlat: Prevent startup of multiple per-cpu threads | expand |
On 3/10/23 11:04, Tero Kristo wrote: > The hwlatd tracer will end up starting multiple per-cpu threads with > the following script: > > #!/bin/sh > cd /sys/kernel/debug/tracing > echo 0 > tracing_on > echo hwlat > current_tracer > echo per-cpu > hwlat_detector/mode > echo 100000 > hwlat_detector/width > echo 200000 > hwlat_detector/window > echo 1 > tracing_on > > To fix the issue, check if the hwlatd thread for the cpu is already > running, before starting a new one. Along with the previous patch, this > avoids running multiple instances of the same CPU thread on the system. > > Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com> Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org> -- Daniel
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c index edc26dc22c3f..c4945f8adc11 100644 --- a/kernel/trace/trace_hwlat.c +++ b/kernel/trace/trace_hwlat.c @@ -492,6 +492,10 @@ static int start_cpu_kthread(unsigned int cpu) { struct task_struct *kthread; + /* Do not start a new hwlatd thread if it is already running */ + if (per_cpu(hwlat_per_cpu_data, cpu).kthread) + return 0; + kthread = kthread_run_on_cpu(kthread_fn, NULL, cpu, "hwlatd/%u"); if (IS_ERR(kthread)) { pr_err(BANNER "could not start sampling thread\n");
The hwlatd tracer will end up starting multiple per-cpu threads with the following script: #!/bin/sh cd /sys/kernel/debug/tracing echo 0 > tracing_on echo hwlat > current_tracer echo per-cpu > hwlat_detector/mode echo 100000 > hwlat_detector/width echo 200000 > hwlat_detector/window echo 1 > tracing_on To fix the issue, check if the hwlatd thread for the cpu is already running, before starting a new one. Along with the previous patch, this avoids running multiple instances of the same CPU thread on the system. Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com> --- v2: * split into separate patch * added reproducer script into commit log kernel/trace/trace_hwlat.c | 4 ++++ 1 file changed, 4 insertions(+)