Skip to contentSkip to conversation

perf/tests: Fix tests 84 and 86 Add --metric-only on s390

PATCH In review Thomas Richter 2 participants 3 messages Apr 15, 2025 – Apr 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/tests: Fix tests 84 and 86 Add --metric-only on s390

On s390x z/VM machines the CPU Measurement Facility is not available. Events cycles and instructions do not exist.
Running above tests on s390 z/VM always fails 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 z/VM machines.

Output after:

 # ./perf test 84 86
 84: perf stat JSON output linter          : Ok
 86: perf stat STD output linter           : Ok
 #
Fixes 45a86d017adf ("perf test: Add --metric-only to perf stat output tests")
Cc Namhyung Kim <[email protected]>
---
 tools/perf/tests/shell/lib/stat_output.sh  | 5 +++++
 tools/perf/tests/shell/stat+json_output.sh | 5 +++++
 2 files changed, 10 insertions(+)
tools/perf/tests/shell/lib/stat_output.sh +5 -0
index 4d4aac547f01..a708dedf7d9d 100644
@@ -151,6 +151,11 @@ check_per_socket()
 check_metric_only()
 {
 	echo -n "Checking $1 output: metric only "
+	if [ "$(uname -m)" = "s390x" ] && grep -q z/VM /proc/sysinfo
+	then
+		echo "[Skip] not supported on z/VM"
+		return
+	fi
 	perf stat --metric-only $2 -e instructions,cycles true
 	commachecker --metric-only
 	echo "[Success]"
tools/perf/tests/shell/stat+json_output.sh +5 -0
index a4f257ea839e..d78e06636a3a 100755
@@ -176,6 +176,11 @@ check_per_socket()
 check_metric_only()
 {
 	echo -n "Checking json output: metric only "
+	if [ "$(uname -m)" = "s390x" ] && grep -q z/VM /proc/sysinfo
+	then
+		echo "[Skip] not supported on z/VM"
+		return
+	fi
 	perf stat -j --metric-only -e instructions,cycles -o "${stat_output}" true
 	$PYTHON $pythonchecker --metric-only --file "${stat_output}"
 	echo "[Success]"
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 8 lines · Thomas Richter

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

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

I would guess this fails also for KVM guests?

tools/perf/tests/shell/lib/stat_output.sh check_per_socket() · line 158

Quoted 13 lines
tools/perf/tests/shell/lib/stat_output.sh +5 -0
index 4d4aac547f01..a708dedf7d9d 100644
@@ -151,6 +151,11 @@ check_per_socket()
 check_metric_only()
 {
 	echo -n "Checking $1 output: metric only "
+	if [ "$(uname -m)" = "s390x" ] && grep -q z/VM /proc/sysinfo
+	then
+		echo "[Skip] not supported on z/VM"
+		return
+	fi

Wouldn't it be better to test for the availability of the CPU-measurement counter facility? That is: test if facility number 67 is present in the facilities field of /proc/cpuinfo.

#2 lore raw
Quoted 11 lines · Heiko Carstens
Quoted 8 lines · Thomas Richter

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

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

I would guess this fails also for KVM guests?

Yes

Quoted 10 lines
Quoted 10 lines
tools/perf/tests/shell/lib/stat_output.sh +1 -0
index 4d4aac547f01..a708dedf7d9d 100644
@@ -151,6 +151,11 @@ check_per_socket()
 check_metric_only()
 {
 	echo -n "Checking $1 output: metric only "
+	if [ "$(uname -m)" = "s390x" ] && grep -q z/VM /proc/sysinfo
Quoted 9 lines

tools/perf/tests/shell/lib/stat_output.sh check_per_socket() · line 158

Quoted 4 lines
tools/perf/tests/shell/lib/stat_output.sh +4 -0
+	then
+		echo "[Skip] not supported on z/VM"
+		return
+	fi

Wouldn't it be better to test for the availability of the CPU-measurement counter facility? That is: test if facility number 67 is present in the facilities field of /proc/cpuinfo.

I can certains change the check and grep for facilities number 67. Will send v2.

Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH

Vorsitzender des Aufsichtsrats: Wolfgang Wendt

Geschäftsführung: David Faller

Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294