• Kan Liang's avatar
    perf/x86/intel: Clean up the hybrid CPU type handling code · b0560bfd
    Kan Liang authored
    There is a fairly long list of grievances about the current code. The
    main beefs:
    
       1. hybrid_big_small assumes that the *HARDWARE* (CPUID) provided
          core types are a bitmap. They are not. If Intel happened to
          make a core type of 0xff, hilarity would ensue.
       2. adl_get_hybrid_cpu_type() utterly inscrutable.  There are
          precisely zero comments and zero changelog about what it is
          attempting to do.
    
    According to Kan, the adl_get_hybrid_cpu_type() is there because some
    Alder Lake (ADL) CPUs can do some silly things. Some ADL models are
    *supposed* to be hybrid CPUs with big and little cores, but there are
    some SKUs that only have big cores. CPUID(0x1a) on those CPUs does
    not say that the CPUs are big cores. It apparently just returns 0x0.
    It confuses perf because it expects to see either 0x40 (Core) or
    0x20 (Atom).
    
    The perf workaround for this is to watch for a CPU core saying it is
    type 0x0. If that happens on an Alder Lake, it calls
    x86_pmu.get_hybrid_cpu_type() and just assumes that the core is a
    Core (0x40) CPU.
    
    To fix up the mess, separate out the CPU types and the 'pmu' types.
    This allows 'hybrid_pmu_type' bitmaps without worrying that some
    future CPU type will set multiple bits.
    
    Since the types are now separate, add a function to glue them back
    together again. Actual comment on the situation in the glue
    function (find_hybrid_pmu_for_cpu()).
    
    Also, give ->get_hybrid_cpu_type() a real return type and make it
    clear that it is overriding the *CPU* type, not the PMU type.
    
    Rename cpu_type to pmu_type in the struct x86_hybrid_pmu to reflect the
    change.
    Originally-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
    Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20230829125806.3016082-6-kan.liang@linux.intel.com
    b0560bfd
perf_event.h 44.1 KB