linux-stable/tools/lib/perf
James Clark f7e36d02d7 libperf: evlist: Fix --cpu argument on hybrid platform
Since the linked fixes: commit, specifying a CPU on hybrid platforms
results in an error because Perf tries to open an extended type event
on "any" CPU which isn't valid. Extended type events can only be opened
on CPUs that match the type.

Before (working):

  $ perf record --cpu 1 -- true
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 2.385 MB perf.data (7 samples) ]

After (not working):

  $ perf record -C 1 -- true
  WARNING: A requested CPU in '1' is not supported by PMU 'cpu_atom' (CPUs 16-27) for event 'cycles:P'
  Error:
  The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu_atom/cycles:P/).
  /bin/dmesg | grep -i perf may provide additional information.

(Ignore the warning message, that's expected and not particularly
relevant to this issue).

This is because perf_cpu_map__intersect() of the user specified CPU (1)
and one of the PMU's CPUs (16-27) correctly results in an empty (NULL)
CPU map. However for the purposes of opening an event, libperf converts
empty CPU maps into an any CPU (-1) which the kernel rejects.

Fix it by deleting evsels with empty CPU maps in the specific case where
user requested CPU maps are evaluated.

Fixes: 251aa04024 ("perf parse-events: Wildcard most "numeric" events")
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20241114160450.295844-2-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2024-12-11 09:19:44 -08:00
..
Documentation libperf: Explicitly specify install-html dependencies 2024-09-26 15:45:48 -07:00
include tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values 2024-10-02 14:58:03 -07:00
tests libperf cpumap: Replace usage of perf_cpu_map__new(NULL) with perf_cpu_map__new_online_cpus() 2023-12-12 14:55:13 -03:00
.gitignore libperf: Add gitignore 2024-08-01 12:11:33 -03:00
Build libperf: Change tests to single static and shared binaries 2021-07-07 11:41:58 -03:00
core.c libperf: Move to tools/lib/perf 2020-01-06 11:46:09 -03:00
cpumap.c libperf cpumap: Ensure empty cpumap is NULL from alloc 2024-03-21 10:41:28 -03:00
evlist.c libperf: evlist: Fix --cpu argument on hybrid platform 2024-12-11 09:19:44 -08:00
evsel.c tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values 2024-10-02 14:58:03 -07:00
internal.h libperf: Move to tools/lib/perf 2020-01-06 11:46:09 -03:00
lib.c libperf: Add preadn() 2022-05-23 10:11:12 -03:00
libperf.map libperf cpumap: Add any, empty and min helpers 2024-03-21 10:41:28 -03:00
libperf.pc.template libperf: Move to tools/lib/perf 2020-01-06 11:46:09 -03:00
Makefile perf cpumap: Add reference count checking 2023-04-17 16:50:02 -03:00
mmap.c perf record: Fix comment misspellings 2024-04-26 22:13:10 -03:00
threadmap.c libperf: Add API for allocating new thread map array 2022-02-23 14:40:23 -03:00
xyarray.c libperf: Move to tools/lib/perf 2020-01-06 11:46:09 -03:00