Re: [PATCH] selftests/ftrace: Skip the sample module BTF probes without module BTF
From: Masami Hiramatsu (Google)
Date: Sat Nov 28 2026 - 04:43:14 EST
On Tue, 24 Nov 2026 13:10:38 -0500, Sasha Levin <sashal@xxxxxxxxxx> wrote:
> btf_probe_event.tc and btf_typecast_accepted.tc probe sample_timer_cb()
> in the trace-events-sample module and cast its argument to struct
> foo_timer_data, so they need the BTF of that module. Without
> CONFIG_DEBUG_INFO_BTF_MODULES the module has no BTF, the probe is
> rejected with "No BTF entry for this probe point" and both tests fail.
>
> A "make kselftest-merge" config can end up without module BTF. The net
> and drivers/net selftest configs set CONFIG_DEBUG_INFO_BTF_MODULES=n,
> and only CONFIG_DEBUG_INFO_BTF_INLINE from the bpf config turns it back
> on, which needs pahole 1.32. KernelCI builds its kselftest kernels this
> way with pahole 1.31, and both tests fail on all the boards that run
> them.
>
> Check for /sys/kernel/btf/trace_events_sample. Without it
> btf_probe_event.tc is unsupported and btf_typecast_accepted.tc skips
> only the sample_timer_cb() probes.
>
> Fixes: 7d8d6ad659c0 ("tracing/probes: Add a new testcase for BTF typecasts")
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
This looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
Shuah, can you pick this to your fixes branch?
Thank you,
> ---
> .../ftrace/test.d/dynevent/btf_probe_event.tc | 3 +++
> .../test.d/dynevent/btf_typecast_accepted.tc | 22 ++++++++++++++-----
> 2 files changed, 19 insertions(+), 6 deletions(-)
>
>
> base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
>
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/btf_probe_event.tc b/tools/testing/selftests/ftrace/test.d/dynevent/btf_probe_event.tc
> index bf71368c31a4a..d832eca058de1 100644
> --- a/tools/testing/selftests/ftrace/test.d/dynevent/btf_probe_event.tc
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/btf_probe_event.tc
> @@ -8,6 +8,9 @@ if ! lsmod | grep -q trace_events_sample; then
> modprobe trace-events-sample || exit_unresolved
> fi
>
> +# The typecast below needs the BTF of the module
> +[ -e /sys/kernel/btf/trace_events_sample ] || exit_unsupported
> +
> echo 0 > events/enable
> echo > dynamic_events
>
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/btf_typecast_accepted.tc b/tools/testing/selftests/ftrace/test.d/dynevent/btf_typecast_accepted.tc
> index dd5552727054c..50d303f7acc9f 100644
> --- a/tools/testing/selftests/ftrace/test.d/dynevent/btf_typecast_accepted.tc
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/btf_typecast_accepted.tc
> @@ -25,6 +25,12 @@ if ! lsmod | grep -q trace_events_sample; then
> modprobe trace-events-sample || exit_unresolved
> fi
>
> +# The sample_timer_cb() probes need the BTF of the module
> +SAMPLE_BTF=
> +if [ -e /sys/kernel/btf/trace_events_sample ] ; then
> + SAMPLE_BTF=yes
> +fi
> +
> if [ "$FPROBES" ] ; then
> # 1. Test basic typecast on fprobe
> echo 'f:fpevent1 vfs_read name=(file)file->f_path.dentry->d_name.name:string' >> dynamic_events
> @@ -42,8 +48,10 @@ if [ "$FPROBES" ] ; then
> echo 'f:fpevent8 vfs_read pid=(task_struct,group_leader)$current->pid' >> dynamic_events
>
> # Test this_cpu_read and this_cpu_ptr on fprobe
> - echo 'f:fpevent9 sample_timer_cb name=(foo_timer_data,timer)t->name:string count=this_cpu_read((foo_timer_data,timer)t->counter)' >> dynamic_events
> - echo 'f:fpevent10 sample_timer_cb ptr=this_cpu_ptr((foo_timer_data,timer)t->counter)' >> dynamic_events
> + if [ "$SAMPLE_BTF" ] ; then
> + echo 'f:fpevent9 sample_timer_cb name=(foo_timer_data,timer)t->name:string count=this_cpu_read((foo_timer_data,timer)t->counter)' >> dynamic_events
> + echo 'f:fpevent10 sample_timer_cb ptr=this_cpu_ptr((foo_timer_data,timer)t->counter)' >> dynamic_events
> + fi
> fi
>
> if [ "$KPROBES" ] ; then
> @@ -63,8 +71,10 @@ if [ "$KPROBES" ] ; then
> echo 'p:kpevent8 vfs_read pid=(task_struct,group_leader)$current->pid' >> dynamic_events
>
> # Test this_cpu_read and this_cpu_ptr on kprobe
> - echo 'p:kpevent9 sample_timer_cb name=(foo_timer_data,timer)t->name:string count=this_cpu_read((foo_timer_data,timer)t->counter)' >> dynamic_events
> - echo 'p:kpevent10 sample_timer_cb ptr=this_cpu_ptr((foo_timer_data,timer)t->counter)' >> dynamic_events
> + if [ "$SAMPLE_BTF" ] ; then
> + echo 'p:kpevent9 sample_timer_cb name=(foo_timer_data,timer)t->name:string count=this_cpu_read((foo_timer_data,timer)t->counter)' >> dynamic_events
> + echo 'p:kpevent10 sample_timer_cb ptr=this_cpu_ptr((foo_timer_data,timer)t->counter)' >> dynamic_events
> + fi
> fi
>
> # Verify the events exist in dynamic_events
> @@ -77,7 +87,7 @@ if [ "$FPROBES" ] ; then
> grep -q "fpevent6 " dynamic_events
> grep -q "fpevent7 " dynamic_events
> grep -q "fpevent8 " dynamic_events
> - if lsmod | grep -q trace_events_sample; then
> + if [ "$SAMPLE_BTF" ] ; then
> grep -q "fpevent9 " dynamic_events
> grep -q "fpevent10 " dynamic_events
> fi
> @@ -92,7 +102,7 @@ if [ "$KPROBES" ] ; then
> grep -q "kpevent6 " dynamic_events
> grep -q "kpevent7 " dynamic_events
> grep -q "kpevent8 " dynamic_events
> - if lsmod | grep -q trace_events_sample; then
> + if [ "$SAMPLE_BTF" ] ; then
> grep -q "kpevent9 " dynamic_events
> grep -q "kpevent10 " dynamic_events
> fi
>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>