Add a flag to track whether the PMU is backed by an Intel CPU. Future support for AMD will sadly need to constantly check whether the PMU is Intel or AMD, and invoking is_intel() every time is rather expensive due to it requiring CPUID (VM-Exit) and a string comparison. Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> --- lib/x86/pmu.c | 5 +++++ lib/x86/pmu.h | 1 + x86/pmu_lbr.c | 2 +- x86/pmu_pebs.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/x86/pmu.c b/lib/x86/pmu.c index ea4859df..837d2a6c 100644 --- a/lib/x86/pmu.c +++ b/lib/x86/pmu.c @@ -6,6 +6,11 @@ void pmu_init(void) { struct cpuid cpuid_10 = cpuid(10); + pmu.is_intel = is_intel(); + + if (!pmu.is_intel) + return; + pmu.version = cpuid_10.a & 0xff; if (pmu.version > 1) { diff --git a/lib/x86/pmu.h b/lib/x86/pmu.h index e2c0bdf4..460e2a19 100644 --- a/lib/x86/pmu.h +++ b/lib/x86/pmu.h @@ -48,6 +48,7 @@ #define MAX_NUM_LBR_ENTRY 32 struct pmu_caps { + bool is_intel; u8 version; u8 nr_fixed_counters; u8 fixed_counter_width; diff --git a/x86/pmu_lbr.c b/x86/pmu_lbr.c index 36c9a8fa..40b63fa3 100644 --- a/x86/pmu_lbr.c +++ b/x86/pmu_lbr.c @@ -47,7 +47,7 @@ int main(int ac, char **av) setup_vm(); - if (!is_intel()) { + if (!pmu.is_intel) { report_skip("PMU_LBR test is for intel CPU's only"); return report_summary(); } diff --git a/x86/pmu_pebs.c b/x86/pmu_pebs.c index 3b6bcb2c..894ae6c7 100644 --- a/x86/pmu_pebs.c +++ b/x86/pmu_pebs.c @@ -392,7 +392,7 @@ int main(int ac, char **av) if (pmu_has_full_writes()) pmu_activate_full_writes(); - if (!is_intel()) { + if (!pmu.is_intel) { report_skip("PEBS requires Intel ICX or later, non-Intel detected"); return report_summary(); } else if (!pmu_has_pebs()) { -- 2.38.1.431.g37b22c650d-goog