Skip to contentSkip to conversation

perf test stat: Avoid hybrid assumption when virtualized

PATCH Applied Ian Rogers 4 participants 5 messages Dec 12, 2024 – Jan 13, 2025 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH v2 1/1 perf test stat: Avoid hybrid assumption when virtualized

The cycles event will fallback to task-clock in the hybrid test when running virtualized. Change the test to not fail for this.

Fixes a6b8bb2addd0 ("perf test: Add a test for default perf stat command")
---
 tools/perf/tests/shell/stat.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +5 -1
index 5a2ca2bcf94d..da42427bb077 100755
@@ -163,7 +163,11 @@ test_hybrid() {
   # Run default Perf stat
   cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/|  cycles  " | wc -l)
 
-  if [ "$pmus" -ne "$cycles_events" ]
+  # 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
+  # can fall back to task-clock and so the end count may be 0. Fail if neither
+  # condition holds.
+  if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
   then
     echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
     err=1
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 4 lines · Ian Rogers

The cycles event will fallback to task-clock in the hybrid test when running virtualized. Change the test to not fail for this.

Fixes a6b8bb2addd0 ("perf test: Add a test for default perf stat command")

I cannot find this commit.

Quoted 1 line

Other than that,

Thanks,
Namhyung

Quoted 24 lines
---
 tools/perf/tests/shell/stat.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +5 -1
index 5a2ca2bcf94d..da42427bb077 100755
@@ -163,7 +163,11 @@ test_hybrid() {
   # Run default Perf stat
   cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/|  cycles  " | wc -l)
 
-  if [ "$pmus" -ne "$cycles_events" ]
+  # 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
+  # can fall back to task-clock and so the end count may be 0. Fail if neither
+  # condition holds.
+  if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
   then
     echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
     err=1
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
author reviewer
#2 lore raw
Quoted 8 lines · Namhyung Kim
Quoted 4 lines · Ian Rogers

The cycles event will fallback to task-clock in the hybrid test when running virtualized. Change the test to not fail for this.

Fixes a6b8bb2addd0 ("perf test: Add a test for default perf stat command")

I cannot find this commit.

Sorry, should have been:

Fixes 65d11821910b ("perf test: Add a test for default perf stat command")

Thanks,
Ian

Quoted 33 lines
Quoted 1 line

Other than that,

Thanks,
Namhyung

Quoted 24 lines
---
 tools/perf/tests/shell/stat.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +5 -2
index 5a2ca2bcf94d..da42427bb077 100755
@@ -163,7 +163,11 @@ test_hybrid() {
   # Run default Perf stat
   cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/|  cycles  " | wc -l)
 
-  if [ "$pmus" -ne "$cycles_events" ]
+  # 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
+  # can fall back to task-clock and so the end count may be 0. Fail if neither
+  # condition holds.
+  if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
   then
     echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
     err=1
--

2.47.1.613.gc27f4b7a9f-goog

maintainer Applied
#3 lore raw
Quoted 11 lines · Ian Rogers
Quoted 7 lines · Namhyung Kim
Quoted 4 lines · Ian Rogers

The cycles event will fallback to task-clock in the hybrid test when running virtualized. Change the test to not fail for this.

Fixes a6b8bb2addd0 ("perf test: Add a test for default perf stat command")

I cannot find this commit.

Sorry, should have been:

Fixes 65d11821910b ("perf test: Add a test for default perf stat command")

Thanks, applied to perf-tools-next, there was a minimal fuzz but I fixed it up:

⬢ [acme@toolbox perf-tools-next]$ patch -p1 < ./v2_20241212_irogers_perf_test_stat_avoid_hybrid_assumption_when_virtualized.mbx patching file tools/perf/tests/shell/stat.sh
Hunk #1 succeeded at 187 with fuzz 2 (offset 24 lines).

- Arnaldo

Quoted 36 lines

Thanks,
Ian

Quoted 33 lines
Quoted 1 line

Other than that,

Thanks,
Namhyung

Quoted 24 lines
---
 tools/perf/tests/shell/stat.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +5 -2
index 5a2ca2bcf94d..da42427bb077 100755
@@ -163,7 +163,11 @@ test_hybrid() {
   # Run default Perf stat
   cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/|  cycles  " | wc -l)
 
-  if [ "$pmus" -ne "$cycles_events" ]
+  # 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
+  # can fall back to task-clock and so the end count may be 0. Fail if neither
+  # condition holds.
+  if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
   then
     echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
     err=1
--

2.47.1.613.gc27f4b7a9f-goog

reviewer Reviewed-by on v2 1/1
#4 lore raw
In reply to Ian Rogers
Quoted 16 lines · Ian Rogers

The cycles event will fallback to task-clock in the hybrid test when running virtualized. Change the test to not fail for this.

Fixes a6b8bb2addd0 ("perf test: Add a test for default perf stat command")
---
  tools/perf/tests/shell/stat.sh | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/stat.sh +0 -0
index 5a2ca2bcf94d..da42427bb077 100755
@@ -163,7 +163,11 @@ test_hybrid() {
    # Run default Perf stat
    cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/|  cycles  " | wc -l)

tools/perf/tests/shell/stat.sh test_hybrid() { · line 173

Quoted 10 lines
tools/perf/tests/shell/stat.sh +5 -1
 
-  if [ "$pmus" -ne "$cycles_events" ]
+  # 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
+  # can fall back to task-clock and so the end count may be 0. Fail if neither
+  # condition holds.
+  if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
    then
      echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
      err=1