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

perf tests metric-only perf stat: Fix tests 84 and 86 s390

On s390x KVM and z/VM machines the CPU Measurement Facility is not
available. Events cycles and instructions do not exist. Running above
tests on s390 KVM and z/VM guests always fail with this error:

# ./perf test 84 86
84: perf stat JSON output linter : FAILED!
86: perf stat STD output linter : FAILED!
#

Root cause is command:

# perf stat -j --metric-only -e instructions,cycles -- true
{"metric-value" : "none"}
#

Which fails due to unsupported events and returns "none".
Do not execute this test case on s390 KVM and z/VM machines.

Output after:
# ./perf test 84 86
84: perf stat JSON output linter : Ok
86: perf stat STD output linter : Ok
#

Fixes: 45a86d017adf4d6c ("perf test: Add --metric-only to perf stat output tests")
Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Suggested-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: https://lore.kernel.org/r/20250424133310.37452-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
ccd4b5cd 68cb1567

+10
+5
tools/perf/tests/shell/lib/stat_output.sh
··· 151 151 check_metric_only() 152 152 { 153 153 echo -n "Checking $1 output: metric only " 154 + if [ "$(uname -m)" = "s390x" ] && ! grep '^facilities' /proc/cpuinfo | grep -qw 67 155 + then 156 + echo "[Skip] CPU-measurement counter facility not installed" 157 + return 158 + fi 154 159 perf stat --metric-only $2 -e instructions,cycles true 155 160 commachecker --metric-only 156 161 echo "[Success]"
+5
tools/perf/tests/shell/stat+json_output.sh
··· 176 176 check_metric_only() 177 177 { 178 178 echo -n "Checking json output: metric only " 179 + if [ "$(uname -m)" = "s390x" ] && ! grep '^facilities' /proc/cpuinfo | grep -qw 67 180 + then 181 + echo "[Skip] CPU-measurement counter facility not installed" 182 + return 183 + fi 179 184 perf stat -j --metric-only -e instructions,cycles -o "${stat_output}" true 180 185 $PYTHON $pythonchecker --metric-only --file "${stat_output}" 181 186 echo "[Success]"