Skip to content

Commit 80a5ce1

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel: Check perf metrics feature for each CPU
It might be possible that different CPUs have different CPU metrics on a platform. In this case, writing the GLOBAL_CTRL_EN_PERF_METRICS bit to the GLOBAL_CTRL register of a CPU, which doesn't support the TopDown perf metrics feature, causes MSR access error. Current TopDown perf metrics feature is enumerated using the boot CPU's PERF_CAPABILITIES MSR. The MSR only indicates the boot CPU supports this feature. Check the PERF_CAPABILITIES MSR for each CPU. If any CPU doesn't support the perf metrics feature, disable the feature globally. Fixes: 59a854e ("perf/x86/intel: Support TopDown metrics on Ice Lake") Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20201001211711.25708-1-kan.liang@linux.intel.com
1 parent 010cb00 commit 80a5ce1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

arch/x86/events/intel/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,6 +4083,17 @@ static void intel_pmu_cpu_starting(int cpu)
40834083
if (x86_pmu.counter_freezing)
40844084
enable_counter_freeze();
40854085

4086+
/* Disable perf metrics if any added CPU doesn't support it. */
4087+
if (x86_pmu.intel_cap.perf_metrics) {
4088+
union perf_capabilities perf_cap;
4089+
4090+
rdmsrl(MSR_IA32_PERF_CAPABILITIES, perf_cap.capabilities);
4091+
if (!perf_cap.perf_metrics) {
4092+
x86_pmu.intel_cap.perf_metrics = 0;
4093+
x86_pmu.intel_ctrl &= ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS);
4094+
}
4095+
}
4096+
40864097
if (!cpuc->shared_regs)
40874098
return;
40884099

0 commit comments

Comments
 (0)