Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lore.kernel.org/lkml/20220506122601.367589-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
d205a3a6 024b3b42

+8 -2
+8 -2
tools/perf/util/auxtrace.c
··· 640 640 { 641 641 bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.user_requested_cpus); 642 642 643 - if (per_cpu_mmaps) 644 - return perf_evsel__enable_cpu(&evsel->core, idx); 643 + if (per_cpu_mmaps) { 644 + struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx); 645 + int cpu_map_idx = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu); 646 + 647 + if (cpu_map_idx == -1) 648 + return -EINVAL; 649 + return perf_evsel__enable_cpu(&evsel->core, cpu_map_idx); 650 + } 645 651 646 652 return perf_evsel__enable_thread(&evsel->core, idx); 647 653 }