|
@@ -131,14 +131,23 @@ static void intel_pmu_lbr_filter(struct cpu_hw_events *cpuc);
|
|
|
|
|
|
static void __intel_pmu_lbr_enable(void)
|
|
|
{
|
|
|
- u64 debugctl;
|
|
|
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
|
|
|
+ u64 debugctl, lbr_select = 0;
|
|
|
|
|
|
- if (cpuc->lbr_sel)
|
|
|
- wrmsrl(MSR_LBR_SELECT, cpuc->lbr_sel->config);
|
|
|
+ if (cpuc->lbr_sel) {
|
|
|
+ lbr_select = cpuc->lbr_sel->config;
|
|
|
+ wrmsrl(MSR_LBR_SELECT, lbr_select);
|
|
|
+ }
|
|
|
|
|
|
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
|
|
|
- debugctl |= (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI);
|
|
|
+ debugctl |= DEBUGCTLMSR_LBR;
|
|
|
+ /*
|
|
|
+ * LBR callstack does not work well with FREEZE_LBRS_ON_PMI.
|
|
|
+ * If FREEZE_LBRS_ON_PMI is set, PMI near call/return instructions
|
|
|
+ * may cause superfluous increase/decrease of LBR_TOS.
|
|
|
+ */
|
|
|
+ if (!(lbr_select & LBR_CALL_STACK))
|
|
|
+ debugctl |= DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
|
|
|
wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
|
|
|
}
|
|
|
|