Skip to contentSkip to conversation

perf test: Workload test of metric and metricgroups

PATCH Superseded Ian Rogers 4 participants 8 messages Sep 16, 2021 – Sep 21, 2021 perf events

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH v2 1/1 perf test: Workload test of metric and metricgroups

Test every metric and metricgroup with 'true' as a workload.

---
 tools/perf/tests/shell/stat_all_metricgroups.sh | 12 ++++++++++++
 tools/perf/tests/shell/stat_all_metrics.sh      | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100755 tools/perf/tests/shell/stat_all_metricgroups.sh
 create mode 100755 tools/perf/tests/shell/stat_all_metrics.sh
tools/perf/tests/shell/stat_all_metricgroups.sh new file +12 -0
new file mode 100755
index 000000000000..de24d374ce24
@@ -0,0 +1,12 @@
+#!/bin/sh
+# perf all metricgroups test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in $(perf list --raw-dump metricgroups); do
+  echo "Testing $m"
+  perf stat -M "$m" true
+done
+
+exit 0
tools/perf/tests/shell/stat_all_metrics.sh new file +16 -0
new file mode 100755
index 000000000000..81b19ba27e68
@@ -0,0 +1,16 @@
+#!/bin/sh
+# perf all metrics test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in `perf list --raw-dump metrics`; do
+  echo "Testing $m"
+  result=$(perf stat -M "$m" true)
+  if [[ "$result" =~ "$m" ]]; then
+    echo "Metric not printed: $m"
+    exit 1
+  fi
+done
+
+exit 0
Signature · 1 line
2.33.0.309.g3052b89438-goog
Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

thanks,
jirka

Quoted 50 lines
---
 tools/perf/tests/shell/stat_all_metricgroups.sh | 12 ++++++++++++
 tools/perf/tests/shell/stat_all_metrics.sh      | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100755 tools/perf/tests/shell/stat_all_metricgroups.sh
 create mode 100755 tools/perf/tests/shell/stat_all_metrics.sh
tools/perf/tests/shell/stat_all_metricgroups.sh new file +12 -0
new file mode 100755
index 000000000000..de24d374ce24
@@ -0,0 +1,12 @@
+#!/bin/sh
+# perf all metricgroups test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in $(perf list --raw-dump metricgroups); do
+  echo "Testing $m"
+  perf stat -M "$m" true
+done
+
+exit 0
tools/perf/tests/shell/stat_all_metrics.sh new file +16 -0
new file mode 100755
index 000000000000..81b19ba27e68
@@ -0,0 +1,16 @@
+#!/bin/sh
+# perf all metrics test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in `perf list --raw-dump metrics`; do
+  echo "Testing $m"
+  result=$(perf stat -M "$m" true)
+  if [[ "$result" =~ "$m" ]]; then
+    echo "Metric not printed: $m"
+    exit 1
+  fi
+done
+
+exit 0
Signature · 1 line
2.33.0.309.g3052b89438-goog
Reviewed-by on v2 1/1
#2 lore raw
In reply to Ian Rogers
Quoted 3 lines · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Note that I also had a local test for pmu events:
for e in $PERF list --raw-dump pmu; do
echo "Testing $e"
result=$($PERF stat -v -e "$e" perf bench internals synthesize) if [[ "$result" =~ "$e" ]]; then
echo "Event not printed: $e"
exit 1
fi
done

Is there any value in upstreaming this? I could not see same already there. Or else make your new script generic, so that it accepts an argument whether to test events or metrics or metricgroups

author reviewer
#3 lore raw
Quoted 18 lines · John Garry
Quoted 3 lines · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Note that I also had a local test for pmu events:
for e in $PERF list --raw-dump pmu; do
echo "Testing $e"
result=$($PERF stat -v -e "$e" perf bench internals synthesize) if [[ "$result" =~ "$e" ]]; then
echo "Event not printed: $e"
exit 1
fi
done

Quoted 3 lines

Is there any value in upstreaming this? I could not see same already there. Or else make your new script generic, so that it accepts an argument whether to test events or metrics or metricgroups

It is not easy to make a generic script with the current shell test infrastructure. I made a variant of this test:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#u
For skylake it ran for 1m15s and so it may be too slow. Perhaps we need to add to the test infrastructure with some kind of speed flag.

Thanks,
Ian

#4 lore raw
Quoted 17 lines · Ian Rogers
Quoted 16 lines · John Garry
Quoted 3 lines · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Note that I also had a local test for pmu events:
for e in $PERF list --raw-dump pmu; do
echo "Testing $e"
result=$($PERF stat -v -e "$e" perf bench internals synthesize) if [[ "$result" =~ "$e" ]]; then
echo "Event not printed: $e"
exit 1
fi
done

Quoted 8 lines
Quoted 3 lines

Is there any value in upstreaming this? I could not see same already there. Or else make your new script generic, so that it accepts an argument whether to test events or metrics or metricgroups

It is not easy to make a generic script with the current shell test infrastructure. I made a variant of this test:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#u
For skylake it ran for 1m15s and so it may be too slow. Perhaps we need to add to the test infrastructure with some kind of speed flag.

Hi Ian,

I suggested this before I realized that it would be called from "perf test".

You think that 1m15s could be considered too slow, but I think that it could be much slower to now run "perf test" on some other systems. Like my arm64 system - see series https://lore.kernel.org/linux-perf-users/[email protected]/T/#t - where I mention that we have >700 HW PMU events (before applying that series to take advantage of the event merging). And each of those events would be tested individually - slow...

So firstly maybe a speed or test level flag could be added before we try this. Sorry for any inconvenience caused.

Thanks,
John

author reviewer
#5 lore raw
Quoted 40 lines · John Garry
Quoted 17 lines · Ian Rogers
Quoted 16 lines · John Garry
Quoted 3 lines · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Note that I also had a local test for pmu events:
for e in $PERF list --raw-dump pmu; do
echo "Testing $e"
result=$($PERF stat -v -e "$e" perf bench internals synthesize) if [[ "$result" =~ "$e" ]]; then
echo "Event not printed: $e"
exit 1
fi
done

Quoted 8 lines
Quoted 3 lines

Is there any value in upstreaming this? I could not see same already there. Or else make your new script generic, so that it accepts an argument whether to test events or metrics or metricgroups

It is not easy to make a generic script with the current shell test infrastructure. I made a variant of this test:
https://lore.kernel.org/linux-perf-users/[email protected]/T/#u
For skylake it ran for 1m15s and so it may be too slow. Perhaps we need to add to the test infrastructure with some kind of speed flag.

Hi Ian,

I suggested this before I realized that it would be called from "perf test".

You think that 1m15s could be considered too slow, but I think that it could be much slower to now run "perf test" on some other systems. Like my arm64 system - see series
https://lore.kernel.org/linux-perf-users/[email protected]/T/#t
- where I mention that we have >700 HW PMU events (before applying that series to take advantage of the event merging). And each of those events would be tested individually - slow...

Quoted 2 lines

So firstly maybe a speed or test level flag could be added before we try this. Sorry for any inconvenience caused.

Hi John,

I think a flag would be best. I'll look to add a notion of test sizes, as that mirrors what works well at Google. We can then tag a test as small, medium, large and default to just say running small and medium tests.

Thanks,
Ian

Quoted 2 lines

Thanks,
John

#6 lore raw
In reply to Ian Rogers
Quoted 1 line · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Good idea! (However...)

Quoted 16 lines
---
 tools/perf/tests/shell/stat_all_metricgroups.sh | 12 ++++++++++++
 tools/perf/tests/shell/stat_all_metrics.sh      | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100755 tools/perf/tests/shell/stat_all_metricgroups.sh
 create mode 100755 tools/perf/tests/shell/stat_all_metrics.sh
tools/perf/tests/shell/stat_all_metricgroups.sh new file +2 -0
new file mode 100755
index 000000000000..de24d374ce24
@@ -0,0 +1,12 @@
+#!/bin/sh
+# perf all metricgroups test

tools/perf/tests/shell/stat_all_metricgroups.sh line 12

Quoted 10 lines
tools/perf/tests/shell/stat_all_metricgroups.sh new file +10 -0
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in $(perf list --raw-dump metricgroups); do
+  echo "Testing $m"
+  perf stat -M "$m" true
+done
+
+exit 0

This always succeeds. Is that what you want? Maybe check the return code from "perf", at least?

Quoted 6 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +0 -0
new file mode 100755
index 000000000000..81b19ba27e68

tools/perf/tests/shell/stat_all_metrics.sh line 9

Quoted 9 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +9 -0
@@ -0,0 +1,16 @@
+#!/bin/sh
+# perf all metrics test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in `perf list --raw-dump metrics`; do
+  echo "Testing $m"
+  result=$(perf stat -M "$m" true)

I don't think this is doing what you want it to do, as it just captures the output of "true", which is always empty.

tools/perf/tests/shell/stat_all_metrics.sh line 10

Quoted 1 line
tools/perf/tests/shell/stat_all_metrics.sh new file +1 -0
+  if [[ "$result" =~ "$m" ]]; then

So this always fails to match, and you'll never fail here, either. :-)

tools/perf/tests/shell/stat_all_metrics.sh line 16

Quoted 6 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +6 -0
+    echo "Metric not printed: $m"
+    exit 1
+  fi
+done
+
+exit 0

You may want to redirect the output of the "perf" command to a temporary file, then grep within that. And, you'll need to remove the file before running the perf command, because if it fails, it will leave any existing file untouched.

Thanks! :-)

PC

author reviewer
#7 lore raw
Quoted 27 lines · Paul A. Clarke
Quoted 1 line · Ian Rogers

Test every metric and metricgroup with 'true' as a workload.

Good idea! (However...)

Quoted 21 lines
---
 tools/perf/tests/shell/stat_all_metricgroups.sh | 12 ++++++++++++
 tools/perf/tests/shell/stat_all_metrics.sh      | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100755 tools/perf/tests/shell/stat_all_metricgroups.sh
 create mode 100755 tools/perf/tests/shell/stat_all_metrics.sh
tools/perf/tests/shell/stat_all_metricgroups.sh new file +7 -0
new file mode 100755
index 000000000000..de24d374ce24
@@ -0,0 +1,12 @@
+#!/bin/sh
+# perf all metricgroups test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in $(perf list --raw-dump metricgroups); do
Quoted 8 lines

tools/perf/tests/shell/stat_all_metricgroups.sh line 12

Quoted 5 lines
tools/perf/tests/shell/stat_all_metricgroups.sh new file +5 -0
+  echo "Testing $m"
+  perf stat -M "$m" true
+done
+
+exit 0

This always succeeds. Is that what you want? Maybe check the return code from "perf", at least?

The "set -e" above means that if the perf command fails then the test exits.

Quoted 19 lines
Quoted 6 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +0 -0
new file mode 100755
index 000000000000..81b19ba27e68

tools/perf/tests/shell/stat_all_metrics.sh line 9

Quoted 9 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +9 -0
@@ -0,0 +1,16 @@
+#!/bin/sh
+# perf all metrics test
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+for m in `perf list --raw-dump metrics`; do
+  echo "Testing $m"
+  result=$(perf stat -M "$m" true)

I don't think this is doing what you want it to do, as it just captures the output of "true", which is always empty.

Quoted 3 lines

tools/perf/tests/shell/stat_all_metrics.sh line 10

Quoted 1 line
tools/perf/tests/shell/stat_all_metrics.sh new file +1 -0
+  if [[ "$result" =~ "$m" ]]; then

So this always fails to match, and you'll never fail here, either. :-)

Doh! Thanks for catching this!

Quoted 10 lines

tools/perf/tests/shell/stat_all_metrics.sh line 16

Quoted 6 lines
tools/perf/tests/shell/stat_all_metrics.sh new file +6 -0
+    echo "Metric not printed: $m"
+    exit 1
+  fi
+done
+
+exit 0

You may want to redirect the output of the "perf" command to a temporary file, then grep within that. And, you'll need to remove the file before running the perf command, because if it fails, it will leave any existing file untouched.

I fixed it by redirecting stderr.

Thanks!
Ian

Quoted 3 lines

Thanks! :-)

PC