summaryrefslogtreecommitdiff
path: root/tools/tracing
diff options
context:
space:
mode:
authorTomas Glozar <tglozar@redhat.com>2025-11-26 15:42:01 +0100
committerTomas Glozar <tglozar@redhat.com>2026-01-07 15:57:16 +0100
commit0304a3b7ec9a207637ab6f360a41af5fb25e1f44 (patch)
treef14918df75d14e2ea124d3f527cfe0b74984f8c9 /tools/tracing
parentf967d1eca7d0bde7c896014577ea876096831c6e (diff)
rtla/timerlat: Add example for BPF action program
Add an example BPF action program that prints the measured latency to the tracefs buffer via bpf_printk(). A new Makefile target, "examples", is added to build the example. In addition, "sample/" subfolder is renamed to "example". If BPF skeleton support is unavailable or disabled, a warning will be displayed when building the BPF action program example. Link: https://lore.kernel.org/r/20251126144205.331954-4-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Diffstat (limited to 'tools/tracing')
-rw-r--r--tools/tracing/rtla/Makefile9
-rw-r--r--tools/tracing/rtla/example/timerlat_bpf_action.c16
-rw-r--r--tools/tracing/rtla/example/timerlat_load.py (renamed from tools/tracing/rtla/sample/timerlat_load.py)0
3 files changed, 24 insertions, 1 deletions
diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 746ccf2f5808..5f1529ce3693 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -73,9 +73,15 @@ src/timerlat.bpf.o: src/timerlat.bpf.c
src/timerlat.skel.h: src/timerlat.bpf.o
$(QUIET_GENSKEL)$(SYSTEM_BPFTOOL) gen skeleton $< > $@
+
+example/timerlat_bpf_action.o: example/timerlat_bpf_action.c
+ $(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -c $(filter %.c,$^) -o $@
else
src/timerlat.skel.h:
$(Q)echo '/* BPF skeleton is disabled */' > src/timerlat.skel.h
+
+example/timerlat_bpf_action.o: example/timerlat_bpf_action.c
+ $(Q)echo "BPF skeleton support is disabled, skipping example/timerlat_bpf_action.o"
endif
$(RTLA): $(RTLA_IN)
@@ -96,7 +102,8 @@ clean: doc_clean fixdep-clean
$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)rm -f rtla rtla-static fixdep FEATURE-DUMP rtla-*
$(Q)rm -rf feature
- $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h
+ $(Q)rm -f src/timerlat.bpf.o src/timerlat.skel.h example/timerlat_bpf_action.o
check: $(RTLA)
RTLA=$(RTLA) prove -o -f tests/
+examples: example/timerlat_bpf_action.o
.PHONY: FORCE clean check
diff --git a/tools/tracing/rtla/example/timerlat_bpf_action.c b/tools/tracing/rtla/example/timerlat_bpf_action.c
new file mode 100644
index 000000000000..ac1be049a848
--- /dev/null
+++ b/tools/tracing/rtla/example/timerlat_bpf_action.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/bpf.h>
+#include <bpf/bpf_tracing.h>
+
+char LICENSE[] SEC("license") = "GPL";
+
+struct trace_event_raw_timerlat_sample {
+ unsigned long long timer_latency;
+} __attribute__((preserve_access_index));
+
+SEC("tp/timerlat_action")
+int action_handler(struct trace_event_raw_timerlat_sample *tp_args)
+{
+ bpf_printk("Latency: %lld\n", tp_args->timer_latency);
+ return 0;
+}
diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtla/example/timerlat_load.py
index a819c3588073..a819c3588073 100644
--- a/tools/tracing/rtla/sample/timerlat_load.py
+++ b/tools/tracing/rtla/example/timerlat_load.py