mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/4] perf off-cpu: Use the CPU map index for the bpf-output file descriptor
@ 2026-10-27 17:04 Ian Rogers
  2026-10-27 17:04 ` [PATCH v1 2/4] perf off-cpu: Write the sample ID for PERF_SAMPLE_ID Ian Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ian Rogers @ 2026-10-27 17:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Ankur Arora, Howard Chu, Thomas Falcon, linux-perf-users,
	linux-kernel

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@google.com>
---
 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");
-- 
2.56.0.313.g2479322e68-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-27 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 17:04 [PATCH v1 1/4] perf off-cpu: Use the CPU map index for the bpf-output file descriptor Ian Rogers
2026-10-27 17:04 ` [PATCH v1 2/4] perf off-cpu: Write the sample ID for PERF_SAMPLE_ID Ian Rogers
2026-10-27 17:04 ` [PATCH v1 3/4] perf off-cpu: Fix cgroup_filter map sizing Ian Rogers
2026-10-27 17:04 ` [PATCH v1 4/4] libperf evlist: Recompute CPU map when an evsel goes system wide Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®