public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Richter <tmricht@linux.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-perf-users@vger.kernel.org, acme@kernel.org,
	namhyung@kernel.org, james.clark@linaro.org, irogers@google.com
Cc: agordeev@linux.ibm.com, gor@linux.ibm.com,
	sumanthk@linux.ibm.com, hca@linux.ibm.com, japo@linux.ibm.com,
	Thomas Richter <tmricht@linux.ibm.com>
Subject: [PATCH V2] perf test: Fix test perf stat tests for virtualized machines
Date: Wed,  7 Jan 2026 14:32:16 +0100	[thread overview]
Message-ID: <20260107133216.2070400-1-tmricht@linux.ibm.com> (raw)

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


             reply	other threads:[~2026-01-07 13:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 13:32 Thomas Richter [this message]
2026-01-07 15:30 ` [PATCH V2] perf test: Fix test perf stat tests for virtualized machines James Clark
2026-01-08 18:03   ` Ian Rogers
2026-01-12 18:51     ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260107133216.2070400-1-tmricht@linux.ibm.com \
    --to=tmricht@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=japo@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=sumanthk@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox