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

perf test: Make all metrics test more tolerant

Metric names are truncated so don't try to match all of one.

Allow AMX metrics to skip as floating point ones do.

Metrics for optane memory can also skip rather than fail.

Add a system wide check for uncore metrics.

Restructure code to avoid extensive nesting.

Some impetus for this in:

https://lore.kernel.org/lkml/d32376b5-5538-ff00-6620-e74ad4b4abf2@huawei.com/

Suggested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20220707153449.202409-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
29d97dee c7a774d7

+31 -16
+31 -16
tools/perf/tests/shell/stat_all_metrics.sh
··· 1 - #!/bin/sh 1 + #!/bin/bash 2 2 # perf all metrics test 3 3 # SPDX-License-Identifier: GPL-2.0 4 - 5 - set -e 6 4 7 5 err=0 8 6 for m in $(perf list --raw-dump metrics); do 9 7 echo "Testing $m" 10 8 result=$(perf stat -M "$m" true 2>&1) 11 - if [[ ! "$result" =~ "$m" ]] && [[ ! "$result" =~ "<not supported>" ]]; then 12 - # We failed to see the metric and the events are support. Possibly the 13 - # workload was too small so retry with something longer. 14 - result=$(perf stat -M "$m" perf bench internals synthesize 2>&1) 15 - if [[ ! "$result" =~ "$m" ]]; then 16 - echo "Metric '$m' not printed in:" 17 - echo "$result" 18 - if [[ "$result" =~ "FP_ARITH" && "$err" != "1" ]]; then 19 - echo "Skip, not fail, for FP issues" 20 - err=2 21 - else 22 - err=1 23 - fi 9 + if [[ "$result" =~ "${m:0:50}" ]] || [[ "$result" =~ "<not supported>" ]] 10 + then 11 + continue 12 + fi 13 + # Failed so try system wide. 14 + result=$(perf stat -M "$m" -a true 2>&1) 15 + if [[ "$result" =~ "${m:0:50}" ]] 16 + then 17 + continue 18 + fi 19 + # Failed again, possibly the workload was too small so retry with something 20 + # longer. 21 + result=$(perf stat -M "$m" perf bench internals synthesize 2>&1) 22 + if [[ "$result" =~ "${m:0:50}" ]] 23 + then 24 + continue 25 + fi 26 + echo "Metric '$m' not printed in:" 27 + echo "$result" 28 + if [[ "$err" != "1" ]] 29 + then 30 + err=2 31 + if [[ "$result" =~ "FP_ARITH" || "$result" =~ "AMX" ]] 32 + then 33 + echo "Skip, not fail, for FP issues" 34 + elif [[ "$result" =~ "PMM" ]] 35 + then 36 + echo "Skip, not fail, for Optane memory issues" 37 + else 38 + err=1 24 39 fi 25 40 fi 26 41 done