]> git.baikalelectronics.ru Git - kernel.git/commit
libperf tests: Fix test_stat_cpu
authorShunsuke Nakamura <nakamura.shun@fujitsu.com>
Mon, 11 Oct 2021 08:37:04 +0000 (17:37 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 14 Oct 2021 18:41:35 +0000 (15:41 -0300)
commit9bee067d089f162d0056a038751e3ed104b7da83
treec7e6491c582ab2596c7a33eaef6681d8726fbe68
parent150d818477705eb5aa6ba4a6b564f32ce4adcfb6
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>
tools/lib/perf/tests/test-evlist.c
tools/lib/perf/tests/test-evsel.c