lkml.org 
[lkml]   [2014]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V5 15/16] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode
    Date
    From: Kan Liang <kan.liang@intel.com>

    LBR callstack is designed for PEBS, It does not work well with
    FREEZE_LBRS_ON_PMI for non PEBS event. If FREEZE_LBRS_ON_PMI is set for
    non PEBS event, PMIs near call/return instructions may cause superfluous
    increase/decrease of LBR_TOS.

    This patch modifies __intel_pmu_lbr_enable() to not enable
    FREEZE_LBRS_ON_PMI when LBR operates in callstack mode. We currently
    don't use LBR callstack to capture kernel space callchain, so disabling
    FREEZE_LBRS_ON_PMI should not be a problem.

    Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
    ---
    arch/x86/kernel/cpu/perf_event_intel_lbr.c | 17 +++++++++++++----
    1 file changed, 13 insertions(+), 4 deletions(-)

    diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
    index 5afb21b..fd8fdfa 100644
    --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
    +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
    @@ -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 = &__get_cpu_var(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);
    }

    --
    1.8.3.2


    \
     
     \ /
      Last update: 2014-09-10 16:41    [W:2.142 / U:0.600 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site