[PATCH v6 16/26] perf trace: Open the BPF output event on every CPU for task targets

From: Ian Rogers

Date: Mon Sep 28 2026 - 14:38:40 EST


The bpf-output event is opened per task without inherit, and
__augmented_syscalls__ holds each CPU's event for the first thread in
the thread map. bpf_perf_event_output() only writes to an event active
on the current CPU, so the target's other threads and its children
aren't augmented.

As BPF now picks the target's tasks, open the event system wide. A CPU
event isn't enabled by exec, so for a workload enable it when opened,
BPF waiting for the exec instead.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/builtin-trace.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 81d660bc87b9..ee844210e281 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4784,6 +4784,15 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
if (trace->cgroup)
evlist__set_default_cgroup(trace->evlist, trace->cgroup);

+ /* BPF picks the target's tasks, so take their output on every CPU. */
+ if (trace->syscalls.events.bpf_output && !target__has_cpu(&trace->opts.target)) {
+ struct evsel *bpf_output = trace->syscalls.events.bpf_output;
+
+ bpf_output->core.system_wide = true;
+ /* Exec doesn't enable a CPU event, BPF waits for the exec instead. */
+ bpf_output->immediate = target__enable_on_exec(&trace->opts.target);
+ }
+
create_maps:
err = evlist__create_maps(evlist, &trace->opts.target);
if (err < 0) {
--
2.56.0.rc1.315.gc6ed9934b7-goog