From: Adrian Hunter Date: Fri, 6 May 2022 12:25:43 +0000 (+0300) Subject: perf auxtrace: Do not mix up mmap idx X-Git-Tag: v6.1-rc5~1270^2~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d205a3a665158f4229845aaa29245b19a9e4be03;p=platform%2Fkernel%2Flinux-starfive.git perf auxtrace: Do not mix up mmap idx The idx is with respect to evlist not evsel. That hasn't mattered because they are the same at present. Prepare for that not being the case, which it won't be when sideband tracking events are allowed on all CPUs even when auxtrace is limited to selected CPUs. Signed-off-by: Adrian Hunter Acked-by: Ian Rogers Cc: Alexey Bayduraev Cc: Jiri Olsa Cc: Leo Yan Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/20220506122601.367589-6-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 10936a3..b11549a 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -640,8 +640,14 @@ static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, { bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.user_requested_cpus); - if (per_cpu_mmaps) - return perf_evsel__enable_cpu(&evsel->core, idx); + if (per_cpu_mmaps) { + struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx); + int cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu); + + if (cpu_map_idx == -1) + return -EINVAL; + return perf_evsel__enable_cpu(&evsel->core, cpu_map_idx); + } return perf_evsel__enable_thread(&evsel->core, idx); }