Thomas Richter
4062fb5268
perf test stat tests: Fix for virtualized machines
...
[ Upstream commit e272628902 ]
On s390 'perf test's '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: bb6e7cb11d ("perf tools: Add fallback for exclude_guest")
Reviewed-by: Ian Rogers <irogers@google.com >
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com >
Cc: Alexander Gordeev <agordeev@linux.ibm.com >
Cc: Heiko Carstens <hca@linux.ibm.com >
Cc: Jan Polensky <japo@linux.ibm.com >
Cc: linux-s390@vger.kernel.org
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2026-03-04 07:20:49 -05:00
Ian Rogers
99dc6b1674
perf test stat: Update test expectations and events
...
[ Upstream commit a48cd551d7 ]
test_stat_record_report and test_stat_record_script used default
output which triggers a bug when sending metrics. As this isn't
relevant to the test switch to using named software events.
Update the match in test_hybrid as the cycles event is now cpu-cycles
to workaround potential ARM issues.
Signed-off-by: Ian Rogers <irogers@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Stable-dep-of: e272628902 ("perf test stat tests: Fix for virtualized machines")
Signed-off-by: Sasha Levin <sashal@kernel.org >
2026-03-04 07:20:49 -05:00
Ian Rogers
55fd40390e
perf test stat: Avoid hybrid assumption when virtualized
...
commit f9c506fb69 upstream.
The cycles event will fallback to task-clock in the hybrid test when
running virtualized. Change the test to not fail for this.
Fixes: 65d1182191 ("perf test: Add a test for default perf stat command")
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241212173354.9860-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2025-10-19 16:34:06 +02:00
Namhyung Kim
f49a92fe57
perf tools: Add fallback for exclude_guest
...
[ Upstream commit bb6e7cb11d ]
Commit 7b100989b4 ("perf evlist: Remove __evlist__add_default")
changed to parse "cycles:P" event instead of creating a new cycles
event for perf record. But it also changed the way how modifiers are
handled so it doesn't set the exclude_guest bit by default.
It seems Apple M1 PMU requires exclude_guest set and returns EOPNOTSUPP
if not. Let's add a fallback so that it can work with default events.
Also update perf stat hybrid tests to handle possible u or H modifiers.
Reviewed-by: Ian Rogers <irogers@google.com >
Reviewed-by: James Clark <james.clark@linaro.org >
Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com >
Acked-by: Kan Liang <kan.liang@linux.intel.com >
Cc: James Clark <james.clark@arm.com >
Cc: Atish Patra <atishp@atishpatra.org >
Cc: Mingwei Zhang <mizhang@google.com >
Cc: Kajol Jain <kjain@linux.ibm.com >
Cc: Thomas Richter <tmricht@linux.ibm.com >
Cc: Palmer Dabbelt <palmer@rivosinc.com >
Link: https://lore.kernel.org/r/20241016062359.264929-2-namhyung@kernel.org
Fixes: 7b100989b4 ("perf evlist: Remove __evlist__add_default")
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Stable-dep-of: 24937ee839 ("perf evsel: Ensure the fallback message is always written to")
Signed-off-by: Sasha Levin <sashal@kernel.org >
2025-10-19 16:33:37 +02:00
James Clark
b01c2dd679
perf test: Add a test for default perf stat command
...
[ Upstream commit 65d1182191 ]
Test that one cycles event is opened for each core PMU when "perf stat"
is run without arguments.
The event line can either be output as "pmu/cycles/" or just "cycles" if
there is only one PMU. Include 2 spaces for padding in the one PMU case
to avoid matching when the word cycles is included in metric
descriptions.
Acked-by: Namhyung Kim <namhyung@kernel.org >
Acked-by: Kan Liang <kan.liang@linux.intel.com >
Signed-off-by: James Clark <james.clark@linaro.org >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Will Deacon <will@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: ak@linux.intel.com
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: Yanteng Si <siyanteng@loongson.cn >
Cc: Sun Haiyong <sunhaiyong@loongson.cn >
Cc: John Garry <john.g.garry@oracle.com >
Link: https://lore.kernel.org/r/20240926144851.245903-8-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Stable-dep-of: 24937ee839 ("perf evsel: Ensure the fallback message is always written to")
Signed-off-by: Sasha Levin <sashal@kernel.org >
2025-10-19 16:33:37 +02:00
Ian Rogers
c0d68601cb
perf test: Add cputype testing to perf stat
...
Check a bogus PMU fails and that a known PMU succeeds. Limit to PMUs
known cpu, cpu_atom and armv8_pmuv3_0 ones.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Kan Liang <kan.liang@linux.intel.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ahmad Yasin <ahmad.yasin@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Caleb Biggers <caleb.biggers@intel.com >
Cc: Edward Baker <edward.baker@intel.com >
Cc: Florian Fischer <florian.fischer@muhq.space >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kajol Jain <kjain@linux.ibm.com >
Cc: Kang Minchul <tegongkang@gmail.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Perry Taylor <perry.taylor@intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Rob Herring <robh@kernel.org >
Cc: Samantha Alt <samantha.alt@intel.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Thomas Richter <tmricht@linux.ibm.com >
Cc: Tiezhu Yang <yangtiezhu@loongson.cn >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com >
Cc: Yang Jihong <yangjihong1@huawei.com >
Link: https://lore.kernel.org/r/20230513063447.464691-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-05-15 09:18:43 -03:00
Sandipan Das
8669862388
perf test: Add stat test for record and script
...
When using the global aggregation mode, running perf script after perf
stat record can result in a segmentation fault as seen with commit
8b76a3188b ("perf stat: Remove unused perf_counts.aggr field").
Add a basic test to the existing suite of stat-related tests for
checking if that workflow runs without erroring out.
Signed-off-by: Sandipan Das <sandipan.das@amd.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ananth Narayan <ananth.narayan@amd.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Nick Terrell <terrelln@fb.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Link: https://lore.kernel.org/r/6a5429879764e3dac984cbb11ee2d95cc1604161.1683280603.git.sandipan.das@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-05-10 14:36:18 -03:00
Tiezhu Yang
818448e9cf
perf tools: Use "grep -E" instead of "egrep"
...
The latest version of grep claims the egrep is now obsolete so the build
now contains warnings that look like:
egrep: warning: egrep is obsolescent; using grep -E
fix this up by moving the related file to use "grep -E" instead.
sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/perf`
Here are the steps to install the latest grep:
wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
tar xf grep-3.8.tar.gz
cd grep-3.8 && ./configure && make
sudo make install
export PATH=/usr/local/bin:$PATH
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn >
Acked-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: http://lore.kernel.org/lkml/1668762999-9297-1-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-12-14 15:28:19 -03:00
Ian Rogers
0c361c6eab
perf test: Stat test for repeat with a weak group
...
Breaking a weak group requires multiple passes of an evlist, with
multiple runs this can introduce bugs ultimately leading to
segfaults. Add a test to cover this.
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: 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/20220822213352.75721-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-08-27 11:55:17 -03:00
Ian Rogers
0dd9769f0c
perf stat: Add stat record+report test
...
This would have caught:
"Subject: Re: perf stat report segfaults"
https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Dave Marchevsky <davemarchevsky@fb.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Lv Ruyi <lv.ruyi@zte.com.cn >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Martin KaFai Lau <kafai@fb.com >
Cc: Michael Petlan <mpetlan@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Quentin Monnet <quentin@isovalent.com >
Cc: Song Liu <songliubraving@fb.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com >
Cc: Yonghong Song <yhs@fb.com >
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: https://lore.kernel.org/r/20220519032005.1273691-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-05-23 09:51:55 -03:00
Ian Rogers
6a973e2919
perf test: Add basic stat and topdown group test
...
Add a basic stat test.
Add two tests of grouping behavior for topdown events. Topdown events
are special as they must be grouped with the slots event first.
Reviewed-by: Kan Liang <kan.liang@linux.intel.com >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Florian Fischer <florian.fischer@muhq.space >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.garry@huawei.com >
Cc: Kim Phillips <kim.phillips@amd.com >
Cc: Madhavan Srinivasan <maddy@linux.ibm.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Riccardo Mancini <rickyman7@gmail.com >
Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com >
Cc: Stephane Eranian <eranian@google.com >
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com >
Link: https://lore.kernel.org/r/20220517052724.283874-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-05-17 12:02:30 -03:00