perf test: Fix test perf stat tests for virtualized machines
Subsystems (2)
PATCH v2 1/1 perf test: Fix test perf stat tests for virtualized machines
V1 --> V2: Add correct Fixes: tag, suggested by James Clark
On s390 perf test 'perf stat tests', subtest test_hybrid fails for z/VM systems.
The root cause is this statement:
$(perf stat -a -- sleep 0.1 2>&1 |\
grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* -c)The perf stat output on a s390 z/VM system is
# perf stat -a -- sleep 0.1 2>&1 Performance counter stats for 'system wide':
56 context-switches # 46.3 cs/sec cs_per_second
1,210.41 msec cpu-clock # 11.9 CPUs CPUs_utilized
12 cpu-migrations # 9.9 migrations/sec ...
81 page-faults # 66.9 faults/sec ...0.100891009 seconds time elapsed
The grep command does not match any single line and exits with error code 1. As the bash script is executed with set -e, it aborts with the first error code being non-zero.
Fix this and use wc -l to count matching lines instead of grep ... -c.
Output before:
# perf test 102 102: perf stat tests : FAILED! # Output after: # perf test 102 102: perf stat tests : Ok #
--- tools/perf/tests/shell/stat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +1 -1
@@ -233,7 +233,7 @@ test_hybrid() { fi # Run default Perf stat - cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " -c) + cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " | wc -l) # The expectation is that default output will have a cycles events on each # hybrid PMU. In situations with no cycles PMU events, like virtualized, this
Signature · 1 line
2.52.0
Quoted 50 lines · Thomas Richter
V1 --> V2: Add correct Fixes: tag, suggested by James Clark
On s390 perf test 'perf stat tests', subtest
test_hybridfails for z/VM systems.
The root cause is this statement:$(perf stat -a -- sleep 0.1 2>&1 |\ grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* -c)The perf stat output on a s390 z/VM system is
# perf stat -a -- sleep 0.1 2>&1 Performance counter stats for 'system wide':56 context-switches # 46.3 cs/sec cs_per_second 1,210.41 msec cpu-clock # 11.9 CPUs CPUs_utilized 12 cpu-migrations # 9.9 migrations/sec ... 81 page-faults # 66.9 faults/sec ...0.100891009 seconds time elapsedThe grep command does not match any single line and exits with error code 1. As the bash script is executed with set -e, it aborts with the first error code being non-zero.
Fix this and use wc -l to count matching lines instead of grep ... -c.
Output before:
# perf test 102 102: perf stat tests : FAILED! # Output after: # perf test 102 102: perf stat tests : Ok #Fixes bb6e7cb11d97c ("perf tools: Add fallback for exclude_guest")Cc James Clark <[email protected]>Cc Ian Rogers <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Thomas Richter <[email protected]>--- tools/perf/tests/shell/stat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/tests/shell/stat.sh +0
-0
tools/perf/tests/shell/stat.sh test_hybrid() { · line 239
Quoted 8 lines
tools/perf/tests/shell/stat.sh +1
-1@@ -233,7 +233,7 @@ test_hybrid() { fi # Run default Perf stat - cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " -c) + cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " | wc -l) # The expectation is that default output will have a cycles events on each # hybrid PMU. In situations with no cycles PMU events, like virtualized, this
Quoted 56 lines · James Clark
Quoted 52 lines · Thomas Richter
V1 --> V2: Add correct Fixes: tag, suggested by James Clark
On s390 perf test 'perf stat tests', subtest
test_hybridfails for z/VM systems.
The root cause is this statement:$(perf stat -a -- sleep 0.1 2>&1 |\ grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* -c)The perf stat output on a s390 z/VM system is
# perf stat -a -- sleep 0.1 2>&1 Performance counter stats for 'system wide':56 context-switches # 46.3 cs/sec cs_per_second 1,210.41 msec cpu-clock # 11.9 CPUs CPUs_utilized 12 cpu-migrations # 9.9 migrations/sec ... 81 page-faults # 66.9 faults/sec ...0.100891009 seconds time elapsedThe grep command does not match any single line and exits with error code 1. As the bash script is executed with set -e, it aborts with the first error code being non-zero.
Fix this and use wc -l to count matching lines instead of grep ... -c.
Output before:
# perf test 102 102: perf stat tests : FAILED! # Output after: # perf test 102 102: perf stat tests : Ok #Fixes bb6e7cb11d97c ("perf tools: Add fallback for exclude_guest")Cc James Clark <[email protected]>Cc Ian Rogers <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Thomas Richter <[email protected]>--- tools/perf/tests/shell/stat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/tests/shell/stat.sh +0
-0@@ -233,7 +233,7 @@ test_hybrid() { fi
Quoted 8 lines
tools/perf/tests/shell/stat.sh test_hybrid() { · line 239
Quoted 6 lines
tools/perf/tests/shell/stat.sh +1
-1# Run default Perf stat - cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " -c) + cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " | wc -l) # The expectation is that default output will have a cycles events on each # hybrid PMU. In situations with no cycles PMU events, like virtualized, thisReviewed-by James Clark <[email protected]>
Thanks,
Ian
Quoted 8 lines · Ian Rogers
Quoted 5 lines · James Clark
Quoted 2 lines · Thomas Richter
# The expectation is that default output will have a cycles events on each # hybrid PMU. In situations with no cycles PMU events, like virtualized, this
Reviewed-by James Clark <[email protected]>Reviewed-by Ian Rogers <[email protected]>
Thanks, applied to perf-tools-next,
- Arnaldo