Skip to content

Commit 9f4a397

Browse files
Dapeng MiPeter Zijlstra
authored andcommitted
perf/x86/intel: Support hybrid PMU with multiple atom uarchs
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Kan Liang <[email protected]> Tested-by: Yongwei Ma <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2eb2802 commit 9f4a397

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
@@ -4924,17 +4924,26 @@ static struct x86_hybrid_pmu *find_hybrid_pmu_for_cpu(void)
49244924

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

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

49404949
return NULL;
@@ -6238,8 +6247,9 @@ static inline int intel_pmu_v6_addr_offset(int index, bool eventsel)
62386247
}
62396248

62406249
static const struct { enum hybrid_pmu_type id; char *name; } intel_hybrid_pmu_type_map[] __initconst = {
6241-
{ hybrid_small, "cpu_atom" },
6242-
{ hybrid_big, "cpu_core" },
6250+
{ hybrid_small, "cpu_atom" },
6251+
{ hybrid_big, "cpu_core" },
6252+
{ hybrid_tiny, "cpu_lowpower" },
62436253
};
62446254

62456255
static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
@@ -6272,7 +6282,7 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
62726282
0, x86_pmu_num_counters(&pmu->pmu), 0, 0);
62736283

62746284
pmu->intel_cap.capabilities = x86_pmu.intel_cap.capabilities;
6275-
if (pmu->pmu_type & hybrid_small) {
6285+
if (pmu->pmu_type & hybrid_small_tiny) {
62766286
pmu->intel_cap.perf_metrics = 0;
62776287
pmu->intel_cap.pebs_output_pt_available = 1;
62786288
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)