* [PATCH v1] perf test: Add cputype testing to perf stat
@ 2023-05-13 6:34 Ian Rogers
2023-05-15 12:19 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2023-05-13 6:34 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Kan Liang, Ahmad Yasin, Peter Zijlstra,
Ingo Molnar, Stephane Eranian, Andi Kleen, Perry Taylor,
Samantha Alt, Caleb Biggers, Weilin Wang, Edward Baker,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Adrian Hunter, Florian Fischer, Rob Herring, Zhengjun Xing,
John Garry, Kajol Jain, Sumanth Korikkar, Thomas Richter,
Tiezhu Yang, Ravi Bangoria, Leo Yan, Yang Jihong, James Clark,
Suzuki Poulouse, Kang Minchul, Athira Rajeev, linux-perf-users,
linux-kernel
Cc: Ian Rogers
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>
---
tools/perf/tests/shell/stat.sh | 44 ++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
index b154fbb15d54..3f1e67795490 100755
--- a/tools/perf/tests/shell/stat.sh
+++ b/tools/perf/tests/shell/stat.sh
@@ -103,10 +103,54 @@ test_topdown_weak_groups() {
echo "Topdown weak groups test [Success]"
}
+test_cputype() {
+ # Test --cputype argument.
+ echo "cputype test"
+
+ # Bogus PMU should fail.
+ if perf stat --cputype="123" -e instructions true > /dev/null 2>&1
+ then
+ echo "cputype test [Bogus PMU didn't fail]"
+ err=1
+ return
+ fi
+
+ # Find a known PMU for cputype.
+ pmu=""
+ for i in cpu cpu_atom armv8_pmuv3_0
+ do
+ if test -d "/sys/devices/$i"
+ then
+ pmu="$i"
+ break
+ fi
+ if perf stat -e "$i/instructions/" true > /dev/null 2>&1
+ then
+ pmu="$i"
+ break
+ fi
+ done
+ if test "x$pmu" = "x"
+ then
+ echo "cputype test [Skipped known PMU not found]"
+ return
+ fi
+
+ # Test running with cputype produces output.
+ if ! perf stat --cputype="$pmu" -e instructions true 2>&1 | grep -E -q "instructions"
+ then
+ echo "cputype test [Failed count missed with given filter]"
+ err=1
+ return
+ fi
+ echo "cputype test [Success]"
+}
+
test_default_stat
test_stat_record_report
test_stat_record_script
test_stat_repeat_weak_groups
test_topdown_groups
test_topdown_weak_groups
+test_cputype
exit $err
--
2.40.1.606.ga4b1b128d6-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1] perf test: Add cputype testing to perf stat
2023-05-13 6:34 [PATCH v1] perf test: Add cputype testing to perf stat Ian Rogers
@ 2023-05-15 12:19 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-05-15 12:19 UTC (permalink / raw)
To: Ian Rogers
Cc: Kan Liang, Ahmad Yasin, Peter Zijlstra, Ingo Molnar,
Stephane Eranian, Andi Kleen, Perry Taylor, Samantha Alt,
Caleb Biggers, Weilin Wang, Edward Baker, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Namhyung Kim, Adrian Hunter,
Florian Fischer, Rob Herring, Zhengjun Xing, John Garry,
Kajol Jain, Sumanth Korikkar, Thomas Richter, Tiezhu Yang,
Ravi Bangoria, Leo Yan, Yang Jihong, James Clark, Suzuki Poulouse,
Kang Minchul, Athira Rajeev, linux-perf-users, linux-kernel
Em Fri, May 12, 2023 at 11:34:47PM -0700, Ian Rogers escreveu:
> Check a bogus PMU fails and that a known PMU succeeds. Limit to PMUs
> known cpu, cpu_atom and armv8_pmuv3_0 ones.
Thanks, applied.
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/tests/shell/stat.sh | 44 ++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
> index b154fbb15d54..3f1e67795490 100755
> --- a/tools/perf/tests/shell/stat.sh
> +++ b/tools/perf/tests/shell/stat.sh
> @@ -103,10 +103,54 @@ test_topdown_weak_groups() {
> echo "Topdown weak groups test [Success]"
> }
>
> +test_cputype() {
> + # Test --cputype argument.
> + echo "cputype test"
> +
> + # Bogus PMU should fail.
> + if perf stat --cputype="123" -e instructions true > /dev/null 2>&1
> + then
> + echo "cputype test [Bogus PMU didn't fail]"
> + err=1
> + return
> + fi
> +
> + # Find a known PMU for cputype.
> + pmu=""
> + for i in cpu cpu_atom armv8_pmuv3_0
> + do
> + if test -d "/sys/devices/$i"
> + then
> + pmu="$i"
> + break
> + fi
> + if perf stat -e "$i/instructions/" true > /dev/null 2>&1
> + then
> + pmu="$i"
> + break
> + fi
> + done
> + if test "x$pmu" = "x"
> + then
> + echo "cputype test [Skipped known PMU not found]"
> + return
> + fi
> +
> + # Test running with cputype produces output.
> + if ! perf stat --cputype="$pmu" -e instructions true 2>&1 | grep -E -q "instructions"
> + then
> + echo "cputype test [Failed count missed with given filter]"
> + err=1
> + return
> + fi
> + echo "cputype test [Success]"
> +}
> +
> test_default_stat
> test_stat_record_report
> test_stat_record_script
> test_stat_repeat_weak_groups
> test_topdown_groups
> test_topdown_weak_groups
> +test_cputype
> exit $err
> --
> 2.40.1.606.ga4b1b128d6-goog
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-15 12:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-13 6:34 [PATCH v1] perf test: Add cputype testing to perf stat Ian Rogers
2023-05-15 12:19 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).