[Patch v3 22/22] perf tools/tests: Add vector registers PEBS sampling test

Dapeng Mi
2025-04-15T08:24:29Z

Current adaptive PEBS supports to capture some vector registers like XMM
register, and arch-PEBS supports to capture wider vector registers like
YMM and ZMM registers. This patch adds a perf test case to verify these
vector registers can be captured correctly.

Suggested-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
tools/perf/tests/shell/record.sh | 55 ++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index ba8d873d3ca7..d85aab09902b 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -116,6 +116,60 @@ test_register_capture() {
echo "Register capture test [Success]"
}

+test_vec_register_capture() {
+ echo "Vector register capture test"
+ if ! perf record -o /dev/null --quiet -e instructions:p true 2> /dev/null
+ then
+ echo "Vector register capture test [Skipped missing event]"
+ return
+ fi
+ if ! perf record --intr-regs=\? 2>&1 | grep -q 'XMM0'
+ then
+ echo "Vector register capture test [Skipped missing XMM registers]"
+ return
+ fi
+ if ! perf record -o - --intr-regs=xmm0 -e instructions:p \
+ -c 100000 ${testprog} 2> /dev/null \
+ | perf script -F ip,sym,iregs -i - 2> /dev/null \
+ | grep -q "XMM0:"
+ then
+ echo "Vector register capture test [Failed missing XMM output]"
+ err=1
+ return
+ fi
+ echo "Vector registe (XMM) capture test [Success]"
+ if ! perf record --intr-regs=\? 2>&1 | grep -q 'YMM0'
+ then
+ echo "Vector register capture test [Skipped missing YMM registers]"
+ return
+ fi
+ if ! perf record -o - --intr-regs=ymm0 -e instructions:p \
+ -c 100000 ${testprog} 2> /dev/null \
+ | perf script -F ip,sym,iregs -i - 2> /dev/null \
+ | grep -q "YMM0:"
+ then
+ echo "Vector register capture test [Failed missing YMM output]"
+ err=1
+ return
+ fi
+ echo "Vector registe (YMM) capture test [Success]"
+ if ! perf record --intr-regs=\? 2>&1 | grep -q 'ZMM0'
+ then
+ echo "Vector register capture test [Skipped missing ZMM registers]"
+ return
+ fi
+ if ! perf record -o - --intr-regs=zmm0 -e instructions:p \
+ -c 100000 ${testprog} 2> /dev/null \
+ | perf script -F ip,sym,iregs -i - 2> /dev/null \
+ | grep -q "ZMM0:"
+ then
+ echo "Vector register capture test [Failed missing ZMM output]"
+ err=1
+ return
+ fi
+ echo "Vector register (ZMM) capture test [Success]"
+}
+
test_system_wide() {
echo "Basic --system-wide mode test"
if ! perf record -aB --synth=no -o "${perfdata}" ${testprog} 2> /dev/null
@@ -318,6 +372,7 @@ fi

test_per_thread
test_register_capture
+test_vec_register_capture
test_system_wide
test_workload
test_branch_counter
--
2.40.1