• Jin Yao's avatar
    perf/x86/intel: Record branch type · d5c7f9dc
    Jin Yao authored
    Perf already has support for disassembling the branch instruction
    and using the branch type for filtering. The patch just records
    the branch type in perf_branch_entry.
    
    Before recording, the patch converts the x86 branch type to
    common branch type.
    
    Change log:
    
    v10: Set the branch_map array to be static. The previous version
         has it on stack then makes the compiler to create it every
         time when the function gets called.
    
    v9: Use __ffs() to find first bit in type in common_branch_type().
        It lets the code be clear.
    
    v8: Change PERF_BR_NONE to PERF_BR_UNKNOWN.
    
    v7: Just convert following x86 branch types to common branch types.
    
    X86_BR_CALL      -> PERF_BR_CALL
    X86_BR_RET       -> PERF_BR_RET
    X86_BR_JCC       -> PERF_BR_COND
    X86_BR_JMP       -> PERF_BR_UNCOND
    X86_BR_IND_CALL  -> PERF_BR_IND_CALL
    X86_BR_ZERO_CALL -> PERF_BR_CALL
    X86_BR_IND_JMP   -> PERF_BR_IND
    X86_BR_SYSCALL   -> PERF_BR_SYSCALL
    X86_BR_SYSRET    -> PERF_BR_SYSRET
    
    Others are set to PERF_BR_NONE
    
    v6: Not changed.
    
    v5: Just fix the merge error. No other update.
    
    v4: Comparing to previous version, the major changes are:
    
    1. Uses a lookup table to convert x86 branch type to common branch
       type.
    
    2. Move the JCC forward/JCC backward and cross page computing to
       user space.
    
    3. Initialize branch type to 0 in intel_pmu_lbr_read_32 and
       intel_pmu_lbr_read_64
    Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
    Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
    Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Kan Liang <kan.liang@intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Link: http://lkml.kernel.org/r/1500379995-6449-3-git-send-email-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    d5c7f9dc
lbr.c 30.7 KB