Skip to content

Commit 4b4191b

Browse files
sean-jcbonzini
authored andcommitted
perf/x86: Refuse to export capabilities for hybrid PMUs
Now that KVM disables vPMU support on hybrid CPUs, WARN and return zeros if perf_get_x86_pmu_capability() is invoked on a hybrid CPU. The helper doesn't provide an accurate accounting of the PMU capabilities for hybrid CPUs and needs to be enhanced if KVM, or anything else outside of perf, wants to act on the PMU capabilities. Cc: [email protected] Cc: Andrew Cooper <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kan Liang <[email protected]> Cc: Andi Kleen <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4d7404e commit 4b4191b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/x86/events/core.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,17 +2974,19 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
29742974

29752975
void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
29762976
{
2977-
if (!x86_pmu_initialized()) {
2977+
/* This API doesn't currently support enumerating hybrid PMUs. */
2978+
if (WARN_ON_ONCE(cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) ||
2979+
!x86_pmu_initialized()) {
29782980
memset(cap, 0, sizeof(*cap));
29792981
return;
29802982
}
29812983

2982-
cap->version = x86_pmu.version;
29832984
/*
2984-
* KVM doesn't support the hybrid PMU yet.
2985-
* Return the common value in global x86_pmu,
2986-
* which available for all cores.
2985+
* Note, hybrid CPU models get tracked as having hybrid PMUs even when
2986+
* all E-cores are disabled via BIOS. When E-cores are disabled, the
2987+
* base PMU holds the correct number of counters for P-cores.
29872988
*/
2989+
cap->version = x86_pmu.version;
29882990
cap->num_counters_gp = x86_pmu.num_counters;
29892991
cap->num_counters_fixed = x86_pmu.num_counters_fixed;
29902992
cap->bit_width_gp = x86_pmu.cntval_bits;

0 commit comments

Comments
 (0)