Skip to content

Commit 059d9a1

Browse files
committed
perf/x86/intel: Support hybrid PMU with multiple atom uarchs
JIRA: https://issues.redhat.com/browse/RHEL-20094 upstream ======== commit 9f4a397 Author: Dapeng Mi <dapeng1.mi@linux.intel.com> Date: Tue Aug 20 07:38:52 2024 +0000 description =========== The upcoming ARL-H hybrid processor contains 2 different atom uarchs which have different PMU capabilities. To distinguish these atom uarchs, CPUID.1AH.EAX[23:0] defines a native model ID which can be used to uniquely identify the uarch of the core by combining with core type. Thus a 3rd hybrid pmu type "hybrid_tiny" is defined to mark the 2nd atom uarch. The helper find_hybrid_pmu_for_cpu() would compare the hybrid pmu type and dynamically read core native id from cpu to identify the corresponding hybrid pmu structure. Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Tested-by: Yongwei Ma <yongwei.ma@intel.com> Link: https://lkml.kernel.org/r/20240820073853.1974746-4-dapeng1.mi@linux.intel.com Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 511af16 commit 059d9a1

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

arch/x86/events/intel/core.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,17 +4923,26 @@ static struct x86_hybrid_pmu *find_hybrid_pmu_for_cpu(void)
49234923

49244924
/*
49254925
* This essentially just maps between the 'hybrid_cpu_type'
4926-
* and 'hybrid_pmu_type' enums:
4926+
* and 'hybrid_pmu_type' enums except for ARL-H processor
4927+
* which needs to compare atom uarch native id since ARL-H
4928+
* contains two different atom uarchs.
49274929
*/
49284930
for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
49294931
enum hybrid_pmu_type pmu_type = x86_pmu.hybrid_pmu[i].pmu_type;
4932+
u32 native_id;
49304933

4931-
if (cpu_type == HYBRID_INTEL_CORE &&
4932-
pmu_type == hybrid_big)
4933-
return &x86_pmu.hybrid_pmu[i];
4934-
if (cpu_type == HYBRID_INTEL_ATOM &&
4935-
pmu_type == hybrid_small)
4934+
if (cpu_type == HYBRID_INTEL_CORE && pmu_type == hybrid_big)
49364935
return &x86_pmu.hybrid_pmu[i];
4936+
if (cpu_type == HYBRID_INTEL_ATOM) {
4937+
if (x86_pmu.num_hybrid_pmus == 2 && pmu_type == hybrid_small)
4938+
return &x86_pmu.hybrid_pmu[i];
4939+
4940+
native_id = get_this_hybrid_cpu_native_id();
4941+
if (native_id == skt_native_id && pmu_type == hybrid_small)
4942+
return &x86_pmu.hybrid_pmu[i];
4943+
if (native_id == cmt_native_id && pmu_type == hybrid_tiny)
4944+
return &x86_pmu.hybrid_pmu[i];
4945+
}
49374946
}
49384947

49394948
return NULL;
@@ -6244,8 +6253,9 @@ static inline int intel_pmu_v6_addr_offset(int index, bool eventsel)
62446253
}
62456254

62466255
static const struct { enum hybrid_pmu_type id; char *name; } intel_hybrid_pmu_type_map[] __initconst = {
6247-
{ hybrid_small, "cpu_atom" },
6248-
{ hybrid_big, "cpu_core" },
6256+
{ hybrid_small, "cpu_atom" },
6257+
{ hybrid_big, "cpu_core" },
6258+
{ hybrid_tiny, "cpu_lowpower" },
62496259
};
62506260

62516261
static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
@@ -6278,7 +6288,7 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
62786288
0, x86_pmu_num_counters(&pmu->pmu), 0, 0);
62796289

62806290
pmu->intel_cap.capabilities = x86_pmu.intel_cap.capabilities;
6281-
if (pmu->pmu_type & hybrid_small) {
6291+
if (pmu->pmu_type & hybrid_small_tiny) {
62826292
pmu->intel_cap.perf_metrics = 0;
62836293
pmu->intel_cap.pebs_output_pt_available = 1;
62846294
pmu->mid_ack = true;

arch/x86/events/perf_event.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ enum {
668668
#define PERF_PEBS_DATA_SOURCE_GRT_MAX 0x10
669669
#define PERF_PEBS_DATA_SOURCE_GRT_MASK (PERF_PEBS_DATA_SOURCE_GRT_MAX - 1)
670670

671+
/*
672+
* CPUID.1AH.EAX[31:0] uniquely identifies the microarchitecture
673+
* of the core. Bits 31-24 indicates its core type (Core or Atom)
674+
* and Bits [23:0] indicates the native model ID of the core.
675+
* Core type and native model ID are defined in below enumerations.
676+
*/
671677
enum hybrid_cpu_type {
672678
HYBRID_INTEL_NONE,
673679
HYBRID_INTEL_ATOM = 0x20,
@@ -676,13 +682,23 @@ enum hybrid_cpu_type {
676682

677683
#define X86_HYBRID_PMU_ATOM_IDX 0
678684
#define X86_HYBRID_PMU_CORE_IDX 1
685+
#define X86_HYBRID_PMU_TINY_IDX 2
679686

680687
enum hybrid_pmu_type {
681688
not_hybrid,
682689
hybrid_small = BIT(X86_HYBRID_PMU_ATOM_IDX),
683690
hybrid_big = BIT(X86_HYBRID_PMU_CORE_IDX),
691+
hybrid_tiny = BIT(X86_HYBRID_PMU_TINY_IDX),
692+
693+
/* The belows are only used for matching */
694+
hybrid_big_small = hybrid_big | hybrid_small,
695+
hybrid_small_tiny = hybrid_small | hybrid_tiny,
696+
hybrid_big_small_tiny = hybrid_big | hybrid_small_tiny,
697+
};
684698

685-
hybrid_big_small = hybrid_big | hybrid_small, /* only used for matching */
699+
enum atom_native_id {
700+
cmt_native_id = 0x2, /* Crestmont */
701+
skt_native_id = 0x3, /* Skymont */
686702
};
687703

688704
struct x86_hybrid_pmu {

0 commit comments

Comments
 (0)