* [PATCH v1] perf test: Skip Intel TPEBS under hypervisor
@ 2025-01-27 21:17 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2025-01-27 21:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, James Clark, Weilin Wang,
linux-perf-users, linux-kernel
Intel TPEBS test skips on non-Intel CPUs. On Intel CPUs under a
hypervisor the cache-misses event may not be present. Skip the test
under this condition.
Refactor the output code to be placed in a file so that on a signal
the file can be dumped. This was necessary to catch the issue above as
the failing perf record command would fail without output.
Signed-off-by: Ian Rogers <irogers@google.com>
---
.../perf/tests/shell/test_stat_intel_tpebs.sh | 35 +++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
index 695dcb93bb5e..1b61b219cd2f 100755
--- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh
+++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh
@@ -20,31 +20,38 @@ then
exit 2
fi
+stat_output=$(mktemp /tmp/__perf_stat_tpebs_output.XXXXX)
+
cleanup() {
+ rm -rf "${stat_output}"
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
+ cat "${stat_output}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
-# Use this event for testing because it should exist in all platforms
-event=cache-misses:R
-
-# Hybrid platforms output like "cpu_atom/cache-misses/R", rather than as above
-alt_name=/cache-misses/R
+# Event to be used in tests
+event=cache-misses
-# Without this cmd option, default value or zero is returned
-#echo "Testing without --record-tpebs"
-#result=$(perf stat -e "$event" true 2>&1)
-#[[ "$result" =~ $event || "$result" =~ $alt_name ]] || exit 1
+if ! perf stat -e "${event}:p" --record-tpebs -a sleep 0.01
+then
+ echo "Missing ${event} support"
+ exit 2
+fi
test_with_record_tpebs() {
echo "Testing with --record-tpebs"
- result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+ if ! perf stat -e "${event}" --record-tpebs -a sleep 0.01 > "${stat_output}" 2>&1
+ then
+ echo "Testing with --record-tpebs [Failed perf stat]"
+ cat "${stat_output}"
+ exit 1
+ fi
# Expected output:
# $ perf stat --record-tpebs -e cache-misses:R -a sleep 0.01
@@ -57,16 +64,16 @@ test_with_record_tpebs() {
# 0 cache-misses:R
#
# 0.013963299 seconds time elapsed
- if [[ ! "$result" =~ "perf record" ]]
+ if ! grep "perf record" "${stat_output}"
then
echo "Testing with --record-tpebs [Failed missing perf record]"
- echo "$result"
+ cat "${stat_output}"
exit 1
fi
- if [[ ! "$result" =~ $event && ! "$result" =~ $alt_name ]]
+ if ! grep "${event}:R" "${stat_output}" && ! grep "/${event}/R" "${stat_output}"
then
echo "Testing with --record-tpebs [Failed missing event name]"
- echo "$result"
+ cat "${stat_output}"
exit 1
fi
echo "Testing with --record-tpebs [Success]"
--
2.48.1.262.g85cc9f2d1e-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-27 21:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-27 21:17 [PATCH v1] perf test: Skip Intel TPEBS under hypervisor Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®