[PATCH v4 12/18] perf test common: Only disable probes in clear_all_probes

From: Ian Rogers

Date: Fri Sep 18 2026 - 17:24:46 EST


clear_all_probes() began by writing 0 to
/sys/kernel/debug/tracing/events/enable, which disables every tracepoint
on the system rather than just the probes the probe tests created. When
tests run in parallel that also silences the events of any concurrent
perf record, perf trace or ftrace session, so unrelated tests lose the
events they are waiting for and fail.

The write cannot simply be dropped. Clearing kprobe_events or
uprobe_events is all or nothing: dyn_events_release_all() walks every
probe of that type first and returns -EBUSY without removing any of them
if it finds one that is still enabled, where enabled means TP_FLAG_TRACE
from tracefs or TP_FLAG_PROFILE from a perf session. A probe left enabled
through tracefs would therefore block the whole clear and leave stale
probes behind to collide with the next run.

Disable the probes and only the probes. The set to disable is taken from
the kprobe_events and uprobe_events listings rather than from a guess at
which groups perf uses, so it matches what dyn_events_release_all() is
going to inspect: a probe an unrelated session left enabled in, say, the
kprobes group would otherwise still abort the clear.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/tests/shell/common/init.sh | 33 ++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/common/init.sh b/tools/perf/tests/shell/common/init.sh
index cbfc78bec974..7c2ca74298ca 100644
--- a/tools/perf/tests/shell/common/init.sh
+++ b/tools/perf/tests/shell/common/init.sh
@@ -130,9 +130,40 @@ check_uprobes_available()
test -e /sys/kernel/debug/tracing/uprobe_events
}

+# Disable every kprobe and uprobe event. The listings name each probe as
+# "TYPE:GROUP/EVENT ARGS...", for instance "p:probe/vfs_read vfs_read", and
+# events/GROUP/EVENT/enable is the switch for it.
+disable_all_probes()
+{
+ PROBE_SPECS=`cat /sys/kernel/debug/tracing/kprobe_events \
+ /sys/kernel/debug/tracing/uprobe_events 2> /dev/null |
+ cut -d ' ' -f 1`
+ for PROBE_SPEC in $PROBE_SPECS
+ do
+ case "$PROBE_SPEC" in
+ *:*/*) ;;
+ *) continue ;;
+ esac
+ PROBE_ENABLE="/sys/kernel/debug/tracing/events/${PROBE_SPEC#*:}/enable"
+ test -e "$PROBE_ENABLE" && echo 0 > "$PROBE_ENABLE"
+ done
+}
+
clear_all_probes()
{
- echo 0 > /sys/kernel/debug/tracing/events/enable
+ # Disable the probes before removing them. Writing to kprobe_events or
+ # uprobe_events is all or nothing: dyn_events_release_all() walks every
+ # probe of that type first and returns -EBUSY without removing any of
+ # them if it finds one that is still enabled, which would leave stale
+ # probes behind to collide with the next run. That covers probes this
+ # test suite never created, so disable all of them and not just the
+ # ones in the groups perf uses.
+ #
+ # Only probes are disabled. Writing to events/enable would also silence
+ # the tracepoints of any perf record, perf trace or ftrace session
+ # sharing the machine, which breaks those tests when they run in
+ # parallel with this one.
+ disable_all_probes
check_kprobes_available && echo > /sys/kernel/debug/tracing/kprobe_events
check_uprobes_available && echo > /sys/kernel/debug/tracing/uprobe_events
}
--
2.55.0.1082.g2b9226bbc0-goog