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

perf test: test case 'Setup struct perf_event_attr' fails on s390 on z/vm

perf test 17 'Setup struct perf_event_attr' fails on s390 z/VM guest,
using linux-next kernel.

Root cause is the fall-back from hardware counter cycles

perf_event_attr:
type 0 (PERF_TYPE_HARDWARE)
size 136
config 0 (PERF_COUNT_HW_CPU_CYCLES)
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|ADDR|PERIOD|DATA_SRC
read_format ID|LOST

which returns -ENOENT on s390 z/VM guest. This causes the code to fall
back to software counter task-clock, as can be seen in the debug output:

------------------------------------------------------------
perf_event_attr:
type 1 (PERF_TYPE_SOFTWARE)
size 136
config 0x1 (PERF_COUNT_SW_TASK_CLOCK) <-here
{ sample_period, sample_freq } 4000
sample_type IP|TID|TIME|ADDR|PERIOD|DATA_SRC
read_format ID|LOST

This succeeds on s390 z/VM guest.

This successful installation of the counter task-clock is not listed in
the expected results and the test case fails.

This is caused by commit eb2eac0c7b618033 ("perf evsel: Fallback to
"task-clock" when not system wide") which introduced fall back from
event 'cycles' to event 'task-clock'.

To fix this on s390 allow event number 0 (cycles) and event number 1
(task-clock) as expected result.

Output before:

# ./perf test -Fv 17
17: Setup struct perf_event_attr :
--- start ---
running './tests/attr/test-stat-group1'
unsupp './tests/attr/test-stat-group1'
running './tests/attr/test-record-graph-default'
test limitation '!aarch64'
excluded architecture list ['aarch64']
expected config=0, got 1
FAILED './tests/attr/test-record-graph-default' - match failure
---- end ----
Setup struct perf_event_attr: FAILED!
#

Output after:

# ./perf test -F 17
17: Setup struct perf_event_attr : Ok
#

Fixes: eb2eac0c7b618033 ("perf evsel: Fallback to "task-clock" when not system wide")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20231219143235.1075522-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Thomas Richter and committed by
Arnaldo Carvalho de Melo
b6d8b858 1e24ce40

+1 -1
+1 -1
tools/perf/tests/attr/base-record
··· 6 6 cpu=* 7 7 type=0|1 8 8 size=136 9 - config=0 9 + config=0|1 10 10 sample_period=* 11 11 sample_type=263 12 12 read_format=0|4|20