From: Tomas Glozar <tglozar@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
John Kacur <jkacur@redhat.com>,
Luis Goncalves <lgoncalv@redhat.com>,
Costa Shulyupin <costa.shul@redhat.com>,
Crystal Wood <crwood@redhat.com>,
Wander Lairson Costa <wander@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Tomas Glozar <tglozar@redhat.com>
Subject: [PATCH v3 3/7] rtla/timerlat: Add example for BPF action program
Date: Mon, 27 Oct 2025 16:33:57 +0100 [thread overview]
Message-ID: <20251027153401.1039217-4-tglozar@redhat.com> (raw)
In-Reply-To: <20251027153401.1039217-1-tglozar@redhat.com>
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.
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
tools/tracing/rtla/Makefile | 9 ++++++++-
tools/tracing/rtla/example/timerlat_bpf_action.c | 16 ++++++++++++++++
.../rtla/{sample => example}/timerlat_load.py | 0
3 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 tools/tracing/rtla/example/timerlat_bpf_action.c
rename tools/tracing/rtla/{sample => example}/timerlat_load.py (100%)
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
similarity index 100%
rename from tools/tracing/rtla/sample/timerlat_load.py
rename to tools/tracing/rtla/example/timerlat_load.py
--
2.51.0
next prev parent reply other threads:[~2025-10-27 15:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 15:33 [PATCH v3 0/7] rtla/timerlat: Add --bpf-action option Tomas Glozar
2025-10-27 15:33 ` [PATCH v3 1/7] rtla/timerlat: Support tail call from BPF program Tomas Glozar
2025-11-03 14:23 ` Wander Lairson Costa
2025-10-27 15:33 ` [PATCH v3 2/7] rtla/timerlat: Add --bpf-action option Tomas Glozar
2025-11-03 14:44 ` Wander Lairson Costa
2025-10-27 15:33 ` Tomas Glozar [this message]
2025-10-27 15:33 ` [PATCH v3 4/7] rtla/tests: Test BPF action program Tomas Glozar
2025-11-03 15:10 ` Wander Lairson Costa
2025-11-03 15:17 ` Tomas Glozar
2025-10-27 15:33 ` [PATCH v3 5/7] rtla/tests: Run Test::Harness in verbose mode Tomas Glozar
2025-11-03 15:11 ` Wander Lairson Costa
2025-10-27 15:34 ` [PATCH v3 6/7] Documentation/rtla: Rename sample/ to example/ Tomas Glozar
2025-11-03 13:41 ` Wander Lairson Costa
2025-10-27 15:34 ` [PATCH v3 7/7] Documentation/rtla: Document --bpf-action option Tomas Glozar
2025-11-03 13:44 ` Wander Lairson Costa
2025-10-31 13:49 ` [PATCH v3 0/7] rtla/timerlat: Add " Crystal Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251027153401.1039217-4-tglozar@redhat.com \
--to=tglozar@redhat.com \
--cc=acme@kernel.org \
--cc=costa.shul@redhat.com \
--cc=crwood@redhat.com \
--cc=jkacur@redhat.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=wander@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).