[PATCH v6 20/26] perf test common: Only disable probes in clear_all_probes

From: Ian Rogers

Date: Mon Sep 28 2026 - 14:37:03 EST


Writing 0 to events/enable disables every tracepoint, breaking perf
sessions running in parallel. Disable just the kprobes and uprobes, an
enabled one would make clearing kprobe_events or uprobe_events fail with
EBUSY.

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

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

+# Disable every kprobe and uprobe, listed as "TYPE:GROUP/EVENT ARGS...".
+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
+ # Any enabled probe makes the clearing below fail with EBUSY. Unlike
+ # events/enable, this leaves other sessions' tracepoints alone.
+ disable_all_probes
check_kprobes_available && echo > /sys/kernel/debug/tracing/kprobe_events
check_uprobes_available && echo > /sys/kernel/debug/tracing/uprobe_events
}
--
2.56.0.rc1.315.gc6ed9934b7-goog