Re: [PATCH v1 1/4] perf off-cpu: Use the CPU map index for the bpf-output file descriptor

From: James Clark

Date: Wed Oct 28 2026 - 05:40:24 EST




On 27/10/2026 17:04, Ian Rogers wrote:
When populating the offcpu_output BPF perf event array, the file
descriptor of the bpf-output event was looked up using the CPU number
rather than the index within the evsel's CPU map. These differ when
CPUs are offline or a subset of CPUs is used, leading to the wrong, or
an out-of-bounds, file descriptor being used. Index the file
descriptor array using the CPU map index.

Fixes: 282c195906c7 ("perf record --off-cpu: Preparation of off-cpu BPF program")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/bpf_off_cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf_off_cpu.c b/tools/perf/util/bpf_off_cpu.c
index c4639f6a5776..ff8935688b43 100644
--- a/tools/perf/util/bpf_off_cpu.c
+++ b/tools/perf/util/bpf_off_cpu.c
@@ -95,7 +95,7 @@ static void off_cpu_start(void *arg)
int cpu_nr = pcpu.cpu;
err = bpf_map__update_elem(skel->maps.offcpu_output, &cpu_nr, sizeof(int),
- xyarray__entry(evsel->core.fd, cpu_nr, 0),
+ xyarray__entry(evsel->core.fd, i, 0),
sizeof(int), BPF_ANY);
if (err) {
pr_err("Failed to update perf event map for direct off-cpu dumping\n");


Reviewed-by: James Clark <james.clark@xxxxxxxxxx>