* [PATCH V2] perf test: Fix test perf stat tests for virtualized machines
@ 2026-01-07 13:32 Thomas Richter
2026-01-07 15:30 ` James Clark
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Richter @ 2026-01-07 13:32 UTC (permalink / raw)
To: linux-kernel, linux-s390, linux-perf-users, acme, namhyung,
james.clark, irogers
Cc: agordeev, gor, sumanthk, hca, japo, Thomas Richter
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
#
Fixes: bb6e7cb11d97c ("perf tools: Add fallback for exclude_guest")
Cc: James Clark <james.clark@linaro.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
tools/perf/tests/shell/stat.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
index 0b2f0f88ca16..792a0b79f6b8 100755
--- a/tools/perf/tests/shell/stat.sh
+++ b/tools/perf/tests/shell/stat.sh
@@ -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
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] perf test: Fix test perf stat tests for virtualized machines
2026-01-07 13:32 [PATCH V2] perf test: Fix test perf stat tests for virtualized machines Thomas Richter
@ 2026-01-07 15:30 ` James Clark
2026-01-08 18:03 ` Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: James Clark @ 2026-01-07 15:30 UTC (permalink / raw)
To: Thomas Richter
Cc: agordeev, gor, sumanthk, hca, japo, linux-kernel, linux-s390,
linux-perf-users, acme, namhyung, irogers
On 07/01/2026 1:32 pm, Thomas Richter wrote:
> 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
> #
>
> Fixes: bb6e7cb11d97c ("perf tools: Add fallback for exclude_guest")
> Cc: James Clark <james.clark@linaro.org>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
> tools/perf/tests/shell/stat.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
> index 0b2f0f88ca16..792a0b79f6b8 100755
> --- a/tools/perf/tests/shell/stat.sh
> +++ b/tools/perf/tests/shell/stat.sh
> @@ -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
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] perf test: Fix test perf stat tests for virtualized machines
2026-01-07 15:30 ` James Clark
@ 2026-01-08 18:03 ` Ian Rogers
2026-01-12 18:51 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2026-01-08 18:03 UTC (permalink / raw)
To: James Clark
Cc: Thomas Richter, agordeev, gor, sumanthk, hca, japo, linux-kernel,
linux-s390, linux-perf-users, acme, namhyung
On Wed, Jan 7, 2026 at 7:30 AM James Clark <james.clark@linaro.org> wrote:
>
>
>
> On 07/01/2026 1:32 pm, Thomas Richter wrote:
> > 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
> > #
> >
> > Fixes: bb6e7cb11d97c ("perf tools: Add fallback for exclude_guest")
> > Cc: James Clark <james.clark@linaro.org>
> > Cc: Ian Rogers <irogers@google.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> > ---
> > tools/perf/tests/shell/stat.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
> > index 0b2f0f88ca16..792a0b79f6b8 100755
> > --- a/tools/perf/tests/shell/stat.sh
> > +++ b/tools/perf/tests/shell/stat.sh
> > @@ -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
>
> Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] perf test: Fix test perf stat tests for virtualized machines
2026-01-08 18:03 ` Ian Rogers
@ 2026-01-12 18:51 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-01-12 18:51 UTC (permalink / raw)
To: Ian Rogers
Cc: James Clark, Thomas Richter, agordeev, gor, sumanthk, hca, japo,
linux-kernel, linux-s390, linux-perf-users, namhyung
On Thu, Jan 08, 2026 at 10:03:49AM -0800, Ian Rogers wrote:
> On Wed, Jan 7, 2026 at 7:30 AM James Clark <james.clark@linaro.org> wrote:
> > On 07/01/2026 1:32 pm, Thomas Richter wrote:
> > > # 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 <james.clark@linaro.org>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-12 18:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 13:32 [PATCH V2] perf test: Fix test perf stat tests for virtualized machines Thomas Richter
2026-01-07 15:30 ` James Clark
2026-01-08 18:03 ` Ian Rogers
2026-01-12 18:51 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.