From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
Like Xu <like.xu.linux@gmail.com>,
Mingwei Zhang <mizhang@google.com>,
Zhenyu Wang <zhenyuw@linux.intel.com>,
Zhang Xiong <xiong.y.zhang@intel.com>,
Lv Zhiyuan <zhiyuan.lv@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>
Subject: [kvm-unit-tests PATCH 2/4] x86/pmu: Iterate over adaptive PEBS flag combinations
Date: Wed, 6 Mar 2024 15:01:51 -0800 [thread overview]
Message-ID: <20240306230153.786365-3-seanjc@google.com> (raw)
In-Reply-To: <20240306230153.786365-1-seanjc@google.com>
Iterate over all possible combinations of adaptive PEBS flags, instead of
simply testing each flag individually. There are currently only 16
possible combinations, i.e. there's no reason not to exhaustively test
every one.
Opportunistically rename PEBS_DATACFG_GP to PEBS_DATACFG_GPRS to
differentiate it from general purposes *counters*, which KVM also tends to
abbreviate as "GP".
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
lib/x86/pmu.h | 6 +++++-
x86/pmu_pebs.c | 20 +++++++++-----------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lib/x86/pmu.h b/lib/x86/pmu.h
index 8465e3c9..f07fbd93 100644
--- a/lib/x86/pmu.h
+++ b/lib/x86/pmu.h
@@ -44,9 +44,13 @@
#define GLOBAL_STATUS_BUFFER_OVF BIT_ULL(GLOBAL_STATUS_BUFFER_OVF_BIT)
#define PEBS_DATACFG_MEMINFO BIT_ULL(0)
-#define PEBS_DATACFG_GP BIT_ULL(1)
+#define PEBS_DATACFG_GPRS BIT_ULL(1)
#define PEBS_DATACFG_XMMS BIT_ULL(2)
#define PEBS_DATACFG_LBRS BIT_ULL(3)
+#define PEBS_DATACFG_MASK (PEBS_DATACFG_MEMINFO | \
+ PEBS_DATACFG_GPRS | \
+ PEBS_DATACFG_XMMS | \
+ PEBS_DATACFG_LBRS)
#define ICL_EVENTSEL_ADAPTIVE (1ULL << 34)
#define PEBS_DATACFG_LBR_SHIFT 24
diff --git a/x86/pmu_pebs.c b/x86/pmu_pebs.c
index 050617cd..dff1ed26 100644
--- a/x86/pmu_pebs.c
+++ b/x86/pmu_pebs.c
@@ -78,13 +78,6 @@ static uint32_t intel_arch_events[] = {
0x412e, /* PERF_COUNT_HW_CACHE_MISSES */
};
-static u64 pebs_data_cfgs[] = {
- PEBS_DATACFG_MEMINFO,
- PEBS_DATACFG_GP,
- PEBS_DATACFG_XMMS,
- PEBS_DATACFG_LBRS | ((MAX_NUM_LBR_ENTRY -1) << PEBS_DATACFG_LBR_SHIFT),
-};
-
/* Iterating each counter value is a waste of time, pick a few typical values. */
static u64 counter_start_values[] = {
/* if PEBS counter doesn't overflow at all */
@@ -105,7 +98,7 @@ static unsigned int get_adaptive_pebs_record_size(u64 pebs_data_cfg)
if (pebs_data_cfg & PEBS_DATACFG_MEMINFO)
sz += sizeof(struct pebs_meminfo);
- if (pebs_data_cfg & PEBS_DATACFG_GP)
+ if (pebs_data_cfg & PEBS_DATACFG_GPRS)
sz += sizeof(struct pebs_gprs);
if (pebs_data_cfg & PEBS_DATACFG_XMMS)
sz += sizeof(struct pebs_xmm);
@@ -419,9 +412,14 @@ int main(int ac, char **av)
if (!has_baseline)
continue;
- for (j = 0; j < ARRAY_SIZE(pebs_data_cfgs); j++) {
- report_prefix_pushf("Adaptive (0x%lx)", pebs_data_cfgs[j]);
- check_pebs_counters(pebs_data_cfgs[j]);
+ for (j = 0; j <= PEBS_DATACFG_MASK; j++) {
+ u64 pebs_data_cfg = j;
+
+ if (pebs_data_cfg & PEBS_DATACFG_LBRS)
+ pebs_data_cfg |= ((MAX_NUM_LBR_ENTRY -1) << PEBS_DATACFG_LBR_SHIFT);
+
+ report_prefix_pushf("Adaptive (0x%lx)", pebs_data_cfg);
+ check_pebs_counters(pebs_data_cfg);
report_prefix_pop();
}
}
--
2.44.0.278.ge034bb2e1d-goog
next prev parent reply other threads:[~2024-03-06 23:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 23:01 [kvm-unit-tests PATCH 0/4] x86/pmu: PEBS fixes and new testcases Sean Christopherson
2024-03-06 23:01 ` [kvm-unit-tests PATCH 1/4] x86/pmu: Enable PEBS on fixed counters iff baseline PEBS is support Sean Christopherson
2024-03-07 9:22 ` Mi, Dapeng
2024-03-06 23:01 ` Sean Christopherson [this message]
2024-03-06 23:01 ` [kvm-unit-tests PATCH 3/4] x86/pmu: Test adaptive PEBS without any adaptive counters Sean Christopherson
2024-03-07 9:08 ` Like Xu
2024-03-07 9:28 ` Mi, Dapeng
2024-06-05 16:17 ` Sean Christopherson
2024-03-07 10:00 ` Mi, Dapeng
2024-03-06 23:01 ` [kvm-unit-tests PATCH 4/4] x86/pmu: Add a PEBS test to verify the host LBRs aren't leaked to the guest Sean Christopherson
2024-03-07 9:23 ` Like Xu
2024-03-07 9:31 ` Mi, Dapeng
2024-03-07 9:22 ` [kvm-unit-tests PATCH 0/4] x86/pmu: PEBS fixes and new testcases Mi, Dapeng
2024-06-05 23:20 ` Sean Christopherson
2024-06-06 0:51 ` Mi, Dapeng1
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=20240306230153.786365-3-seanjc@google.com \
--to=seanjc@google.com \
--cc=dapeng1.mi@intel.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=xiong.y.zhang@intel.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhiyuan.lv@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