From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Xudong Hao <xudong.hao@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [Patch v9 10/10] perf tests: Add SIMD registers sampling test
Date: Mon, 6 Jul 2026 10:34:44 +0800 [thread overview]
Message-ID: <20260706023444.3067660-11-dapeng1.mi@linux.intel.com> (raw)
In-Reply-To: <20260706023444.3067660-1-dapeng1.mi@linux.intel.com>
Validate that SIMD registers (XMM/YMM/ZMM on x86) can be sampled
correctly with hardware support.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
tools/perf/tests/shell/record.sh | 131 +++++++++++++++++++++++++++++++
1 file changed, 131 insertions(+)
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 48c722e563e2..c98d8028d0b7 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -256,6 +256,136 @@ test_egpr_register_capture() {
echo "eGPR/SSP register capture test [Success]"
}
+extract_x86_advertised_simd_classes() {
+ local regs_output="$1"
+
+ echo "${regs_output}" \
+ | grep -oE '(ZMM|YMM|XMM|OPMASK)[0-9]+-[0-9]+' \
+ | sed -E 's/[0-9]+-[0-9]+$//' \
+ | tr '[:upper:]' '[:lower:]' \
+ | sort -u
+}
+
+ordered_x86_simd_classes() {
+ local advertised_classes="$1"
+ local simd_classes=""
+
+ if echo "${advertised_classes}" | grep -qw zmm
+ then
+ simd_classes="${simd_classes} zmm"
+ fi
+ if echo "${advertised_classes}" | grep -qw ymm
+ then
+ simd_classes="${simd_classes} ymm"
+ fi
+ if echo "${advertised_classes}" | grep -qw xmm
+ then
+ simd_classes="${simd_classes} xmm"
+ fi
+ if echo "${advertised_classes}" | grep -qw opmask
+ then
+ simd_classes="${simd_classes} opmask"
+ fi
+
+ echo "${simd_classes}" | xargs
+}
+
+validate_simd_sampling_mode() {
+ local regs_opt="$1"
+ local simd_classes="$2"
+ local script_field="$3"
+ local simd_class
+ local sample_output
+
+ for simd_class in ${simd_classes}
+ do
+ if ! sample_output=$(perf record -o - "${regs_opt}=${simd_class}" \
+ -e br_inst_retired.near_call -c 1000 --per-thread ${testprog} 2> /dev/null \
+ | perf script -F ip,sym,"${script_field}" -i - 2> /dev/null)
+ then
+ echo "SIMD register capture test [Failed record ${regs_opt}=${simd_class}]"
+ return 1
+ fi
+
+ if ! has_required_regs "${sample_output}" "${simd_class}"
+ then
+ echo "SIMD register capture test [Failed missing ${simd_class} sampling data]"
+ return 1
+ fi
+ done
+
+ return 0
+}
+
+test_simd_register_capture() {
+ local arch
+ local intr_regs
+ local user_regs
+ local simd_classes
+ local user_simd_classes
+ local advertised_intr_classes
+ local advertised_user_classes
+ local tested=0
+
+ echo "SIMD register capture test"
+ if ! perf list pmu | grep -q 'br_inst_retired.near_call'
+ then
+ echo "SIMD register capture test [Skipped missing event]"
+ return
+ fi
+
+ intr_regs=$(perf record --intr-regs=\? 2>&1 || true)
+ user_regs=$(perf record --user-regs=\? 2>&1 || true)
+
+ simd_classes=""
+ user_simd_classes=""
+
+ arch=$(uname -m)
+ case ${arch} in
+ x86_64|i386)
+ advertised_intr_classes=$(extract_x86_advertised_simd_classes "${intr_regs}")
+ advertised_user_classes=$(extract_x86_advertised_simd_classes "${user_regs}")
+
+ simd_classes=$(ordered_x86_simd_classes "${advertised_intr_classes}")
+ user_simd_classes=$(ordered_x86_simd_classes "${advertised_user_classes}")
+ ;;
+ *)
+ ;;
+ esac
+
+ if [ -z "${simd_classes}" ]
+ then
+ echo "SIMD register capture test [Skipped missing intr SIMD registers]"
+ elif ! validate_simd_sampling_mode "--intr-regs" "${simd_classes}" "iregs"
+ then
+ echo "SIMD register capture test [Failed missing intr SIMD register sampling data]"
+ err=1
+ return
+ else
+ tested=1
+ fi
+
+ if [ -z "${user_simd_classes}" ]
+ then
+ echo "SIMD register capture test [Skipped missing user SIMD registers]"
+ elif ! validate_simd_sampling_mode "--user-regs" "${user_simd_classes}" "uregs"
+ then
+ echo "SIMD register capture test [Failed missing user SIMD register sampling data]"
+ err=1
+ return
+ else
+ tested=1
+ fi
+
+ if [ ${tested} -eq 0 ]
+ then
+ echo "SIMD register capture test [Skipped missing SIMD registers]"
+ return
+ fi
+
+ echo "SIMD register capture test [Success]"
+}
+
test_system_wide() {
echo "Basic --system-wide mode test"
local ret=0
@@ -575,6 +705,7 @@ fi
test_per_thread
test_register_capture
test_egpr_register_capture
+test_simd_register_capture
test_system_wide
test_workload
test_branch_counter
--
2.34.1
prev parent reply other threads:[~2026-07-06 2:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 2:34 [Patch v9 00/10] Perf tools: Support eGPRs/SSP/SIMD registers sampling Dapeng Mi
2026-07-06 2:34 ` [Patch v9 01/10] perf dwarf-regs: Fix DWARF register index bounds check Dapeng Mi
2026-07-06 2:34 ` [Patch v9 02/10] perf util: Add missed fields in _attr__fprintf() and __attr_swap() Dapeng Mi
2026-07-06 2:34 ` [Patch v9 03/10] tools headers: Sync x86 headers with kernel sources Dapeng Mi
2026-07-06 2:34 ` [Patch v9 04/10] perf headers: Sync perf_event.h/perf_regs.h with the kernel headers Dapeng Mi
2026-07-06 2:34 ` [Patch v9 05/10] perf regs: Support x86 eGPRs/SSP sampling Dapeng Mi
2026-07-06 2:34 ` [Patch v9 06/10] perf regs: Support x86 SIMD registers sampling Dapeng Mi
2026-07-06 2:34 ` [Patch v9 07/10] perf regs: Enable dumping of SIMD registers Dapeng Mi
2026-07-06 2:34 ` [Patch v9 08/10] perf dwarf-regs: Add SIMD/eGPRs support for x86 DWARF registers Dapeng Mi
2026-07-06 2:34 ` [Patch v9 09/10] perf tests: Add x86 eGPRs/SSP registers sampling test Dapeng Mi
2026-07-06 2:34 ` Dapeng Mi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706023444.3067660-11-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
--cc=zide.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox