[PATCH v2 00/14] perf trace: Fix BPF filtering and make tracing tests non-exclusive

From: Ian Rogers

Date: Thu Sep 17 2026 - 14:49:30 EST


perf trace's BPF augmentation attaches to raw_syscalls:sys_enter and
raw_syscalls:sys_exit system wide, and used the program return value to
decide whether a syscall was interesting. Returning 0 from a
BPF_PROG_TYPE_TRACEPOINT program makes perf_trace_run_bpf_submit() drop
the event for every listener on that tracepoint, not just for the perf
trace that installed the program. Any concurrent perf trace, perf record
or ftrace session watching raw_syscalls therefore lost events, which is
one of the reasons so many of the perf trace and perf probe shell tests
had to be marked (exclusive) and run on their own.

Patch 1 is an independent build fix for the two files the rest of the
series goes on to rework.

Patches 2 to 6 fix perf trace. They stop the return value being used as
a filter and do the filtering in BPF maps instead, fix argument handling
for the __data_loc internal tracepoint fields that syscalls:sys_enter_*
gained in 6.19, stop the sys_exit program array tail calling a sys_enter
augmenter, and replace the userspace PERF_RECORD_FORK/PERF_RECORD_EXIT
bookkeeping with BTF-typed raw tracepoint programs on
sched_process_{fork,exit,exec}. A task is then registered before its
first syscall and evicted in do_exit(), rather than whenever userspace
next drains the ring buffer.

Patches 7 to 14 deal with the tests. Several collided with each other
through global state rather than through perf trace: fixed probe names,
clear_all_probes() disabling tracing events globally, and perf trace's
hardcoded "probe:vfs_getname*" wildcard pinning probes belonging to
other tests. With those scoped to a pid they can drop (exclusive) and
run in parallel again.

Tested on x86_64. The trace and probe tests pass under 'perf test -r3',
which runs the repeats concurrently. Every patch builds individually,
and the series also builds with BUILD_BPF_SKEL=0.

Changes since v1:
- New patch 1 includes <sys/types.h> and <string.h> for the pid_t and
strcmp() uses that were relying on the include chain happening to
drag them in, which does not hold on libcs such as musl.
- Patch 5 no longer returns success when the event qualifier filter
string fails to allocate. err now defaults to 0 because either
tracepoint may legitimately be absent, so the ENOMEM path has to set
the error itself rather than rely on that default. It also includes
<stdbool.h> for the bool parameters it adds to trace_augment.h.
- Patch 7 removes the temporary directory if the cd into it fails.
That happens before the cleanup trap is installed, so the directory
would otherwise be left behind in /tmp.

Ian Rogers (14):
perf trace: Include the headers declaring pid_t and strcmp
perf trace: Start BPF summary before starting workload
perf trace: Skip internal tracepoint fields in formatting and beauty
map
perf trace: Do not set unaugmented BPF program on sys_exit map
perf trace: Filter events in BPF and avoid tracepoint vetoes
perf trace: Handle fork and exit directly in BPF filter maps
perf test test_task_analyzer: Isolate in temporary directory and make
non-exclusive
perf test common: Do not globally disable tracing events in
clear_all_probes
perf test probe_vfs_getname: Scope probe name to PID and make
non-exclusive
perf test record+probe_libc_inet_pton: Scope event to PID, add
retries, and make non-exclusive
perf test trace_summary: Improve error diagnostics
perf test trace_btf_general: Drop --max-events=1 and make
non-exclusive
perf test trace_summary: Make non-exclusive
perf test uprobe_from_different_cu: Scope probe name to PID

tools/perf/Documentation/perf-trace.txt | 5 +
tools/perf/builtin-trace.c | 335 ++++++++++++++----
tools/perf/tests/shell/common/init.sh | 1 -
.../perf/tests/shell/lib/probe_vfs_getname.sh | 34 +-
tools/perf/tests/shell/probe_vfs_getname.sh | 3 +-
.../shell/record+probe_libc_inet_pton.sh | 83 +++--
.../shell/record+script_probe_vfs_getname.sh | 18 +-
tools/perf/tests/shell/test_task_analyzer.sh | 16 +-
.../shell/test_uprobe_from_different_cu.sh | 11 +-
.../tests/shell/trace+probe_vfs_getname.sh | 9 +
tools/perf/tests/shell/trace_btf_general.sh | 8 +-
tools/perf/tests/shell/trace_summary.sh | 14 +-
.../bpf_skel/augmented_raw_syscalls.bpf.c | 291 ++++++++++++++-
tools/perf/util/bpf_trace_augment.c | 174 ++++++++-
tools/perf/util/trace_augment.h | 27 +-
15 files changed, 888 insertions(+), 141 deletions(-)


base-commit: 91b0782fc9e9d2f0a40b5256146e014802fdbb36
--
2.55.0.1082.g2b9226bbc0-goog