From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jim Mattson <jmattson@google.com>,
Mingwei Zhang <mizhang@google.com>,
Zide Chen <zide.chen@intel.com>,
Das Sandipan <Sandipan.Das@amd.com>,
Shukla Manali <Manali.Shukla@amd.com>,
Xiaoyao Li <xiaoyao.li@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>, Yi Lai <yi1.lai@intel.com>
Subject: [kvm-unit-tests patch v3 8/8] x86: pmu_pebs: Support to validate timed PEBS record on GNR/SRF
Date: Wed, 3 Sep 2025 14:46:01 +0800 [thread overview]
Message-ID: <20250903064601.32131-9-dapeng1.mi@linux.intel.com> (raw)
In-Reply-To: <20250903064601.32131-1-dapeng1.mi@linux.intel.com>
On Intel GNR/SRF platform, timed PEBS is introduced. Timed PEBS adds
a new "retired latency" field in basic info group to show the timing
info. IA32_PERF_CAPABILITIES.PEBS_TIMING_INFO[bit 17] is introduced to
indicate whether timed PEBS is supported.
After introducing timed PEBS, the PEBS record format field shrinks to
bits[31:0] and the bits[47:32] is used to record retired latency.
Thus shrink the record format to bits[31:0] accordingly and avoid the
retired latency field is recognized a part of record format to compare
and cause failure on GNR/SRF.
Please find detailed information about timed PEBS in section 8.4.1
"Timed Processor Event Based Sampling" of "Intel Architecture
Instruction Set Extensions and Future Features".
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Tested-by: Yi Lai <yi1.lai@intel.com>
---
lib/x86/pmu.h | 6 ++++++
x86/pmu_pebs.c | 8 +++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/x86/pmu.h b/lib/x86/pmu.h
index c7dc68c1..86a7a05f 100644
--- a/lib/x86/pmu.h
+++ b/lib/x86/pmu.h
@@ -20,6 +20,7 @@
#define PMU_CAP_LBR_FMT 0x3f
#define PMU_CAP_FW_WRITES (1ULL << 13)
#define PMU_CAP_PEBS_BASELINE (1ULL << 14)
+#define PMU_CAP_PEBS_TIMING_INFO (1ULL << 17)
#define PERF_CAP_PEBS_FORMAT 0xf00
#define EVNSEL_EVENT_SHIFT 0
@@ -188,4 +189,9 @@ static inline bool pmu_has_pebs_baseline(void)
return pmu.perf_cap & PMU_CAP_PEBS_BASELINE;
}
+static inline bool pmu_has_pebs_timing_info(void)
+{
+ return pmu.perf_cap & PMU_CAP_PEBS_TIMING_INFO;
+}
+
#endif /* _X86_PMU_H_ */
diff --git a/x86/pmu_pebs.c b/x86/pmu_pebs.c
index 2848cc1e..bc37e8e3 100644
--- a/x86/pmu_pebs.c
+++ b/x86/pmu_pebs.c
@@ -277,6 +277,7 @@ static void check_pebs_records(u64 bitmask, u64 pebs_data_cfg, bool use_adaptive
unsigned int count = 0;
bool expected, pebs_idx_match, pebs_size_match, data_cfg_match;
void *cur_record;
+ u64 format_mask;
expected = (ds->pebs_index == ds->pebs_buffer_base) && !pebs_rec->format_size;
if (!(rdmsr(MSR_CORE_PERF_GLOBAL_STATUS) & GLOBAL_STATUS_BUFFER_OVF)) {
@@ -289,6 +290,8 @@ static void check_pebs_records(u64 bitmask, u64 pebs_data_cfg, bool use_adaptive
return;
}
+ /* Record format shrinks to bits[31:0] after timed PEBS is introduced. */
+ format_mask = pmu_has_pebs_timing_info() ? GENMASK_ULL(31, 0) : GENMASK_ULL(47, 0);
expected = ds->pebs_index >= ds->pebs_interrupt_threshold;
cur_record = (void *)pebs_buffer;
do {
@@ -296,8 +299,7 @@ static void check_pebs_records(u64 bitmask, u64 pebs_data_cfg, bool use_adaptive
pebs_record_size = pebs_rec->format_size >> RECORD_SIZE_OFFSET;
pebs_idx_match = pebs_rec->applicable_counters & bitmask;
pebs_size_match = pebs_record_size == get_pebs_record_size(pebs_data_cfg, use_adaptive);
- data_cfg_match = (pebs_rec->format_size & GENMASK_ULL(47, 0)) ==
- (use_adaptive ? pebs_data_cfg : 0);
+ data_cfg_match = (pebs_rec->format_size & format_mask) == (use_adaptive ? pebs_data_cfg : 0);
expected = pebs_idx_match && pebs_size_match && data_cfg_match;
report(expected,
"PEBS record (written seq %d) is verified (including size, counters and cfg).", count);
@@ -327,7 +329,7 @@ static void check_pebs_records(u64 bitmask, u64 pebs_data_cfg, bool use_adaptive
pebs_record_size, get_pebs_record_size(pebs_data_cfg, use_adaptive));
if (!data_cfg_match)
printf("FAIL: The pebs_data_cfg (0x%lx) doesn't match with the effective MSR_PEBS_DATA_CFG (0x%lx).\n",
- pebs_rec->format_size & 0xffffffffffff, use_adaptive ? pebs_data_cfg : 0);
+ pebs_rec->format_size & format_mask, use_adaptive ? pebs_data_cfg : 0);
}
}
--
2.34.1
next prev parent reply other threads:[~2025-09-03 6:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 6:45 [kvm-unit-tests patch v3 0/8] Fix pmu test errors on GNR/SRF/CWF Dapeng Mi
2025-09-03 6:45 ` [kvm-unit-tests patch v3 1/8] x86/pmu: Add helper to detect Intel overcount issues Dapeng Mi
2025-11-20 22:27 ` Sean Christopherson
2025-11-21 1:18 ` Mi, Dapeng
2025-09-03 6:45 ` [kvm-unit-tests patch v3 2/8] x86/pmu: Relax precise count validation for Intel overcounted platforms Dapeng Mi
2025-09-03 6:45 ` [kvm-unit-tests patch v3 3/8] x86/pmu: Fix incorrect masking of fixed counters Dapeng Mi
2025-11-20 22:28 ` Sean Christopherson
2025-11-21 1:25 ` Mi, Dapeng
2025-09-03 6:45 ` [kvm-unit-tests patch v3 4/8] x86/pmu: Handle instruction overcount issue in overflow test Dapeng Mi
2025-09-03 6:45 ` [kvm-unit-tests patch v3 5/8] x86/pmu: Relax precise count check for emulated instructions tests Dapeng Mi
2025-11-20 22:29 ` Sean Christopherson
2025-11-21 0:53 ` Mi, Dapeng
2025-09-03 6:45 ` [kvm-unit-tests patch v3 6/8] x86/pmu: Expand "llc references" upper limit for broader compatibility Dapeng Mi
2025-09-03 6:46 ` [kvm-unit-tests patch v3 7/8] x86: pmu_pebs: Remove abundant data_cfg_match calculation Dapeng Mi
2025-09-03 6:46 ` Dapeng Mi [this message]
2025-11-20 22:30 ` [kvm-unit-tests patch v3 0/8] Fix pmu test errors on GNR/SRF/CWF Sean Christopherson
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=20250903064601.32131-9-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=Manali.Shukla@amd.com \
--cc=Sandipan.Das@amd.com \
--cc=dapeng1.mi@intel.com \
--cc=jmattson@google.com \
--cc=kan.liang@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=xiaoyao.li@intel.com \
--cc=yi1.lai@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