Skip to content

Commit 08697bc

Browse files
Tero Kristorostedt
authored andcommitted
trace/hwlat: Do not start per-cpu thread if it is already running
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. Link: https://lore.kernel.org/all/20230302113654.2984709-1-tero.kristo@linux.intel.com/ Link: https://lkml.kernel.org/r/20230310100451.3948583-3-tero.kristo@linux.intel.com Cc: stable@vger.kernel.org Fixes: f46b165 ("trace/hwlat: Implement the per-cpu mode") Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com> Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 4c42f5f commit 08697bc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/trace/trace_hwlat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ static int start_cpu_kthread(unsigned int cpu)
492492
{
493493
struct task_struct *kthread;
494494

495+
/* Do not start a new hwlatd thread if it is already running */
496+
if (per_cpu(hwlat_per_cpu_data, cpu).kthread)
497+
return 0;
498+
495499
kthread = kthread_run_on_cpu(kthread_fn, NULL, cpu, "hwlatd/%u");
496500
if (IS_ERR(kthread)) {
497501
pr_err(BANNER "could not start sampling thread\n");

0 commit comments

Comments
 (0)