• Kan Liang's avatar
    perf/x86/intel/lbr: Support LBR_CTL · 49d8184f
    Kan Liang authored
    An IA32_LBR_CTL is introduced for Architecture LBR to enable and config
    LBR registers to replace the previous LBR_SELECT.
    
    All the related members in struct cpu_hw_events and struct x86_pmu
    have to be renamed.
    
    Some new macros are added to reflect the layout of LBR_CTL.
    
    The mapping from PERF_SAMPLE_BRANCH_* to the corresponding bits in
    LBR_CTL MSR is saved in lbr_ctl_map now, which is not a const value.
    The value relies on the CPUID enumeration.
    
    For the previous model-specific LBR, most of the bits in LBR_SELECT
    operate in the suppressed mode. For the bits in LBR_CTL, the polarity is
    inverted.
    
    For the previous model-specific LBR format 5 (LBR_FORMAT_INFO), if the
    NO_CYCLES and NO_FLAGS type are set, the flag LBR_NO_INFO will be set to
    avoid the unnecessary LBR_INFO MSR read. Although Architecture LBR also
    has a dedicated LBR_INFO MSR, perf doesn't need to check and set the
    flag LBR_NO_INFO. For Architecture LBR, XSAVES instruction will be used
    as the default way to read the LBR MSRs all together. The overhead which
    the flag tries to avoid doesn't exist anymore. Dropping the flag can
    save the extra check for the flag in the lbr_read() later, and make the
    code cleaner.
    Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/1593780569-62993-10-git-send-email-kan.liang@linux.intel.com
    49d8184f
lbr.c 36.6 KB