From: Sasha Levin <sashal@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Shuah Khan <shuah@kernel.org>,
linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] selftests/ftrace: Skip the sample module BTF probes without module BTF
Date: Tue, 24 Nov 2026 13:10:38 -0500 [thread overview]
Message-ID: <20261124181038.2362595-1-sashal@kernel.org> (raw)
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@kernel.org>
---
.../ftrace/test.d/dynevent/btf_probe_event.tc | 3 +++
.../test.d/dynevent/btf_typecast_accepted.tc | 22 ++++++++++++++-----
2 files changed, 19 insertions(+), 6 deletions(-)
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
base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
--
2.53.0
reply other threads:[~2026-11-24 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261124181038.2362595-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
/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