[PATCH 6.6 018/201] perf test: Add a test for default perf stat command
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Fri Oct 17 07:51:19 PDT 2025
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <james.clark at linaro.org>
[ Upstream commit 65d11821910bd910a2b4b5b005360d036c76ecef ]
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 at kernel.org>
Acked-by: Kan Liang <kan.liang at linux.intel.com>
Signed-off-by: James Clark <james.clark at linaro.org>
Cc: Yang Jihong <yangjihong at bytedance.com>
Cc: Dominique Martinet <asmadeus at codewreck.org>
Cc: Colin Ian King <colin.i.king at gmail.com>
Cc: Howard Chu <howardchu95 at gmail.com>
Cc: Ze Gao <zegao2021 at gmail.com>
Cc: Yicong Yang <yangyicong at hisilicon.com>
Cc: Weilin Wang <weilin.wang at intel.com>
Cc: Will Deacon <will at kernel.org>
Cc: Mike Leach <mike.leach at linaro.org>
Cc: Jing Zhang <renyu.zj at linux.alibaba.com>
Cc: Yang Li <yang.lee at linux.alibaba.com>
Cc: Leo Yan <leo.yan at linux.dev>
Cc: ak at linux.intel.com
Cc: Athira Rajeev <atrajeev at linux.vnet.ibm.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Yanteng Si <siyanteng at loongson.cn>
Cc: Sun Haiyong <sunhaiyong at loongson.cn>
Cc: John Garry <john.g.garry at oracle.com>
Link: https://lore.kernel.org/r/20240926144851.245903-8-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung at kernel.org>
Stable-dep-of: 24937ee839e4 ("perf evsel: Ensure the fallback message is always written to")
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
tools/perf/tests/shell/stat.sh | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
index 3f1e67795490a..c6df7eec96b98 100755
--- a/tools/perf/tests/shell/stat.sh
+++ b/tools/perf/tests/shell/stat.sh
@@ -146,6 +146,30 @@ test_cputype() {
echo "cputype test [Success]"
}
+test_hybrid() {
+ # Test the default stat command on hybrid devices opens one cycles event for
+ # each CPU type.
+ echo "hybrid test"
+
+ # Count the number of core PMUs, assume minimum of 1
+ pmus=$(ls /sys/bus/event_source/devices/*/cpus 2>/dev/null | wc -l)
+ if [ "$pmus" -lt 1 ]
+ then
+ pmus=1
+ fi
+
+ # Run default Perf stat
+ cycles_events=$(perf stat -- true 2>&1 | grep -E "/cycles/| cycles " | wc -l)
+
+ if [ "$pmus" -ne "$cycles_events" ]
+ then
+ echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
+ err=1
+ return
+ fi
+ echo "hybrid test [Success]"
+}
+
test_default_stat
test_stat_record_report
test_stat_record_script
@@ -153,4 +177,5 @@ test_stat_repeat_weak_groups
test_topdown_groups
test_topdown_weak_groups
test_cputype
+test_hybrid
exit $err
--
2.51.0
More information about the linux-arm-kernel
mailing list