linux/tools/lib/perf
Shunsuke Nakamura 3ff6d64e68 libperf tests: Fix test_stat_cpu
The `cpu` argument of perf_evsel__read() must specify the cpu index.

perf_cpu_map__for_each_cpu() is for iterating the cpu number (not index)
and is thus not appropriate for use with perf_evsel__read().

So, if there is an offline CPU, the cpu number specified in the argument
may point out of range because the cpu number and the cpu index are
different.

Fix test_stat_cpu().

Testing it:

  # make tests -C tools/lib/perf/
  make: Entering directory '/home/nakamura/kernel_src/linux-5.15-rc4_fix/tools/lib/perf'
  running static:
  - running tests/test-cpumap.c...OK
  - running tests/test-threadmap.c...OK
  - running tests/test-evlist.c...OK
  - running tests/test-evsel.c...OK
  running dynamic:
  - running tests/test-cpumap.c...OK
  - running tests/test-threadmap.c...OK
  - running tests/test-evlist.c...OK
  - running tests/test-evsel.c...OK
  make: Leaving directory '/home/nakamura/kernel_src/linux-5.15-rc4_fix/tools/lib/perf'

Signed-off-by: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20211011083704.4108720-1-nakamura.shun@fujitsu.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-10-14 15:41:35 -03:00
..
Documentation libperf: Add evsel mmap support 2021-04-15 16:38:51 -03:00
include libperf tests: Fix verbose printing 2021-08-24 15:05:35 -03:00
tests libperf tests: Fix test_stat_cpu 2021-10-14 15:41:35 -03:00
Build libperf: Change tests to single static and shared binaries 2021-07-07 11:41:58 -03:00
core.c
cpumap.c libperf cpumap: Take into advantage it is sorted to optimize perf_cpu_map__max() 2021-08-31 16:17:02 -03:00
evlist.c libperf: Adopt evlist__set_leader() from tools/perf as perf_evlist__set_leader() 2021-07-09 14:04:32 -03:00
evsel.c libperf evsel: Make use of FD robust. 2021-09-18 17:43:06 -03:00
internal.h
lib.c
libperf.map libperf: Adopt evlist__set_leader() from tools/perf as perf_evlist__set_leader() 2021-07-09 14:04:32 -03:00
libperf.pc.template
Makefile libperf: Change tests to single static and shared binaries 2021-07-07 11:41:58 -03:00
mmap.c libperf: Add support for user space counter access 2021-04-20 08:10:45 -03:00
threadmap.c
xyarray.c