Skip to contentSkip to conversation

rtla/timerlat_bpf: Stop tracing on user latency

PATCH In review Tomas Glozar 2 participants 2 messages Oct 6, 2025 – Oct 17, 2025

Subsystems (3)
lore
Share & tools
lore

Tomas Glozar

author maintainer
#0 lore raw

PATCH 1/1 rtla/timerlat_bpf: Stop tracing on user latency

rtla-timerlat allows a *thread* latency threshold to be set via the -T/--thread option. However, the timerlat tracer calls this *total* latency (stop_tracing_total_us), and stops tracing also when the return-to-user latency is over the threshold.

Change the behavior of the timerlat BPF program to reflect what the timerlat tracer is doing, to avoid discrepancy between stopping collecting data in the BPF program and stopping tracing in the timerlat tracer.

Fixes e34293ddcebd ("rtla/timerlat: Add BPF skeleton to collect samples")
---
 tools/tracing/rtla/src/timerlat.bpf.c | 3 +++
 1 file changed, 3 insertions(+)
tools/tracing/rtla/src/timerlat.bpf.c +3 -0
index 084cd10c21fc..e2265b5d6491 100644
@@ -148,6 +148,9 @@ int handle_timerlat_sample(struct trace_event_raw_timerlat_sample *tp_args)
 	} else {
 		update_main_hist(&hist_user, bucket);
 		update_summary(&summary_user, latency, bucket);
+
+		if (thread_threshold != 0 && latency_us >= thread_threshold)
+			set_stop_tracing();
 	}
 
 	return 0;
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Tomas Glozar

rtla-timerlat allows a *thread* latency threshold to be set via the -T/--thread option. However, the timerlat tracer calls this *total* latency (stop_tracing_total_us), and stops tracing also when the return-to-user latency is over the threshold.

Change the behavior of the timerlat BPF program to reflect what the timerlat tracer is doing, to avoid discrepancy between stopping collecting data in the BPF program and stopping tracing in the timerlat tracer.

Fixes e34293ddcebd ("rtla/timerlat: Add BPF skeleton to collect samples")
---
 tools/tracing/rtla/src/timerlat.bpf.c | 3 +++
 1 file changed, 3 insertions(+)
tools/tracing/rtla/src/timerlat.bpf.c +3 -0
index 084cd10c21fc..e2265b5d6491 100644
@@ -148,6 +148,9 @@ int handle_timerlat_sample(struct trace_event_raw_timerlat_sample *tp_args)
 	} else {
 		update_main_hist(&hist_user, bucket);
 		update_summary(&summary_user, latency, bucket);
+
+		if (thread_threshold != 0 && latency_us >= thread_threshold)
+			set_stop_tracing();
 	}
 
 	return 0;
Signature · 1 line
2.51.0