[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <yha47my7tmcu5yvbwelst32ipectzkhekxdorgpxws463kxsno@fcw5vv674yo6>
Date: Tue, 16 Dec 2025 12:22:10 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Tomas Glozar <tglozar@...hat.com>
Cc: Steven Rostedt <rostedt@...dmis.org>,
LKML <linux-kernel@...r.kernel.org>, Linux Trace Kernel <linux-trace-kernel@...r.kernel.org>,
John Kacur <jkacur@...hat.com>, Luis Goncalves <lgoncalv@...hat.com>,
Costa Shulyupin <costa.shul@...hat.com>, Crystal Wood <crwood@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: Re: [PATCH v4 3/7] rtla/timerlat: Add example for BPF action program
On Wed, Nov 26, 2025 at 03:42:01PM +0100, Tomas Glozar wrote:
> 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@...hat.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 $@
I couldn't understand the need for the `filter` function.
> 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.1
>
Powered by blists - more mailing lists