Skip to content

Commit 9ef08bd

Browse files
committed
perf/x86: Add Lunar Lake and Arrow Lake support
JIRA: https://issues.redhat.com/browse/RHEL-20059 upstream ======== commit a932aa0 Author: Kan Liang <kan.liang@linux.intel.com> Date: Wed Jun 26 07:35:35 2024 -0700 description =========== From PMU's perspective, Lunar Lake and Arrow Lake are similar to the previous generation Meteor Lake. Both are hybrid platforms, with e-core and p-core. The key differences include: - The e-core supports 3 new fixed counters - The p-core supports an updated PEBS Data Source format - More GP counters (Updated event constraint table) - New Architectural performance monitoring V6 (New Perfmon MSRs aliasing, umask2, eq). - New PEBS format V6 (Counters Snapshotting group) - New RDPMC metrics clear mode The legacy features, the 3 new fixed counters and updated event constraint table are enabled in this patch. The new PEBS data source format, the architectural performance monitoring V6, the PEBS format V6, and the new RDPMC metrics clear mode are supported in the following patches. Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Andi Kleen <ak@linux.intel.com> Reviewed-by: Ian Rogers <irogers@google.com> Link: https://lkml.kernel.org/r/20240626143545.480761-4-kan.liang@linux.intel.com Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent 038fa7d commit 9ef08bd

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed

arch/x86/events/intel/core.c

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ static struct event_constraint intel_grt_event_constraints[] __read_mostly = {
219219
EVENT_CONSTRAINT_END
220220
};
221221

222+
static struct event_constraint intel_skt_event_constraints[] __read_mostly = {
223+
FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
224+
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
225+
FIXED_EVENT_CONSTRAINT(0x0300, 2), /* pseudo CPU_CLK_UNHALTED.REF */
226+
FIXED_EVENT_CONSTRAINT(0x013c, 2), /* CPU_CLK_UNHALTED.REF_TSC_P */
227+
FIXED_EVENT_CONSTRAINT(0x0073, 4), /* TOPDOWN_BAD_SPECULATION.ALL */
228+
FIXED_EVENT_CONSTRAINT(0x019c, 5), /* TOPDOWN_FE_BOUND.ALL */
229+
FIXED_EVENT_CONSTRAINT(0x02c2, 6), /* TOPDOWN_RETIRING.ALL */
230+
EVENT_CONSTRAINT_END
231+
};
232+
222233
static struct event_constraint intel_skl_event_constraints[] = {
223234
FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
224235
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
@@ -369,6 +380,55 @@ static struct extra_reg intel_rwc_extra_regs[] __read_mostly = {
369380
EVENT_EXTRA_END
370381
};
371382

383+
static struct event_constraint intel_lnc_event_constraints[] = {
384+
FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
385+
FIXED_EVENT_CONSTRAINT(0x0100, 0), /* INST_RETIRED.PREC_DIST */
386+
FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
387+
FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */
388+
FIXED_EVENT_CONSTRAINT(0x013c, 2), /* CPU_CLK_UNHALTED.REF_TSC_P */
389+
FIXED_EVENT_CONSTRAINT(0x0400, 3), /* SLOTS */
390+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_RETIRING, 0),
391+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_BAD_SPEC, 1),
392+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_FE_BOUND, 2),
393+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_BE_BOUND, 3),
394+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_HEAVY_OPS, 4),
395+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_BR_MISPREDICT, 5),
396+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_FETCH_LAT, 6),
397+
METRIC_EVENT_CONSTRAINT(INTEL_TD_METRIC_MEM_BOUND, 7),
398+
399+
INTEL_UEVENT_CONSTRAINT(0x0148, 0x4),
400+
INTEL_UEVENT_CONSTRAINT(0x0175, 0x4),
401+
402+
INTEL_EVENT_CONSTRAINT(0x2e, 0x3ff),
403+
INTEL_EVENT_CONSTRAINT(0x3c, 0x3ff),
404+
/*
405+
* Generally event codes < 0x90 are restricted to counters 0-3.
406+
* The 0x2E and 0x3C are exception, which has no restriction.
407+
*/
408+
INTEL_EVENT_CONSTRAINT_RANGE(0x01, 0x8f, 0xf),
409+
410+
INTEL_UEVENT_CONSTRAINT(0x01a3, 0xf),
411+
INTEL_UEVENT_CONSTRAINT(0x02a3, 0xf),
412+
INTEL_UEVENT_CONSTRAINT(0x08a3, 0x4),
413+
INTEL_UEVENT_CONSTRAINT(0x0ca3, 0x4),
414+
INTEL_UEVENT_CONSTRAINT(0x04a4, 0x1),
415+
INTEL_UEVENT_CONSTRAINT(0x08a4, 0x1),
416+
INTEL_UEVENT_CONSTRAINT(0x10a4, 0x1),
417+
INTEL_UEVENT_CONSTRAINT(0x01b1, 0x8),
418+
INTEL_UEVENT_CONSTRAINT(0x02cd, 0x3),
419+
INTEL_EVENT_CONSTRAINT(0xce, 0x1),
420+
421+
INTEL_EVENT_CONSTRAINT_RANGE(0xd0, 0xdf, 0xf),
422+
/*
423+
* Generally event codes >= 0x90 are likely to have no restrictions.
424+
* The exception are defined as above.
425+
*/
426+
INTEL_EVENT_CONSTRAINT_RANGE(0x90, 0xfe, 0x3ff),
427+
428+
EVENT_CONSTRAINT_END
429+
};
430+
431+
372432
EVENT_ATTR_STR(mem-loads, mem_ld_nhm, "event=0x0b,umask=0x10,ldlat=3");
373433
EVENT_ATTR_STR(mem-loads, mem_ld_snb, "event=0xcd,umask=0x1,ldlat=3");
374434
EVENT_ATTR_STR(mem-stores, mem_st_snb, "event=0xcd,umask=0x2");
@@ -5796,6 +5856,23 @@ static struct attribute *adl_hybrid_events_attrs[] = {
57965856
NULL,
57975857
};
57985858

5859+
EVENT_ATTR_STR_HYBRID(topdown-retiring, td_retiring_lnl, "event=0xc2,umask=0x02;event=0x00,umask=0x80", hybrid_big_small);
5860+
EVENT_ATTR_STR_HYBRID(topdown-fe-bound, td_fe_bound_lnl, "event=0x9c,umask=0x01;event=0x00,umask=0x82", hybrid_big_small);
5861+
EVENT_ATTR_STR_HYBRID(topdown-be-bound, td_be_bound_lnl, "event=0xa4,umask=0x02;event=0x00,umask=0x83", hybrid_big_small);
5862+
5863+
static struct attribute *lnl_hybrid_events_attrs[] = {
5864+
EVENT_PTR(slots_adl),
5865+
EVENT_PTR(td_retiring_lnl),
5866+
EVENT_PTR(td_bad_spec_adl),
5867+
EVENT_PTR(td_fe_bound_lnl),
5868+
EVENT_PTR(td_be_bound_lnl),
5869+
EVENT_PTR(td_heavy_ops_adl),
5870+
EVENT_PTR(td_br_mis_adl),
5871+
EVENT_PTR(td_fetch_lat_adl),
5872+
EVENT_PTR(td_mem_bound_adl),
5873+
NULL
5874+
};
5875+
57995876
/* Must be in IDX order */
58005877
EVENT_ATTR_STR_HYBRID(mem-loads, mem_ld_adl, "event=0xd0,umask=0x5,ldlat=3;event=0xcd,umask=0x1,ldlat=3", hybrid_big_small);
58015878
EVENT_ATTR_STR_HYBRID(mem-stores, mem_st_adl, "event=0xd0,umask=0x6;event=0xcd,umask=0x2", hybrid_big_small);
@@ -6145,6 +6222,21 @@ static __always_inline void intel_pmu_init_grt(struct pmu *pmu)
61456222
intel_pmu_ref_cycles_ext();
61466223
}
61476224

6225+
static __always_inline void intel_pmu_init_lnc(struct pmu *pmu)
6226+
{
6227+
intel_pmu_init_glc(pmu);
6228+
hybrid(pmu, event_constraints) = intel_lnc_event_constraints;
6229+
hybrid(pmu, pebs_constraints) = intel_lnc_pebs_event_constraints;
6230+
hybrid(pmu, extra_regs) = intel_rwc_extra_regs;
6231+
}
6232+
6233+
static __always_inline void intel_pmu_init_skt(struct pmu *pmu)
6234+
{
6235+
intel_pmu_init_grt(pmu);
6236+
hybrid(pmu, event_constraints) = intel_skt_event_constraints;
6237+
hybrid(pmu, extra_regs) = intel_cmt_extra_regs;
6238+
}
6239+
61486240
__init int intel_pmu_init(void)
61496241
{
61506242
struct attribute **extra_skl_attr = &empty_attrs;
@@ -6870,6 +6962,31 @@ __init int intel_pmu_init(void)
68706962
name = "meteorlake_hybrid";
68716963
break;
68726964

6965+
case INTEL_LUNARLAKE_M:
6966+
case INTEL_ARROWLAKE:
6967+
intel_pmu_init_hybrid(hybrid_big_small);
6968+
6969+
x86_pmu.get_event_constraints = mtl_get_event_constraints;
6970+
x86_pmu.hw_config = adl_hw_config;
6971+
6972+
td_attr = lnl_hybrid_events_attrs;
6973+
mem_attr = mtl_hybrid_mem_attrs;
6974+
tsx_attr = adl_hybrid_tsx_attrs;
6975+
extra_attr = boot_cpu_has(X86_FEATURE_RTM) ?
6976+
mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr;
6977+
6978+
/* Initialize big core specific PerfMon capabilities.*/
6979+
pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX];
6980+
intel_pmu_init_lnc(&pmu->pmu);
6981+
6982+
/* Initialize Atom core specific PerfMon capabilities.*/
6983+
pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX];
6984+
intel_pmu_init_skt(&pmu->pmu);
6985+
6986+
pr_cont("Lunarlake Hybrid events, ");
6987+
name = "lunarlake_hybrid";
6988+
break;
6989+
68736990
default:
68746991
switch (x86_pmu.version) {
68756992
case 1:

arch/x86/events/intel/ds.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,30 @@ struct event_constraint intel_glc_pebs_event_constraints[] = {
10851085
EVENT_CONSTRAINT_END
10861086
};
10871087

1088+
struct event_constraint intel_lnc_pebs_event_constraints[] = {
1089+
INTEL_FLAGS_UEVENT_CONSTRAINT(0x100, 0x100000000ULL), /* INST_RETIRED.PREC_DIST */
1090+
INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x800000000ULL),
1091+
1092+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */
1093+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */
1094+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_INST_RETIRED.LOCK_LOADS */
1095+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x41d0, 0xf), /* MEM_INST_RETIRED.SPLIT_LOADS */
1096+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x42d0, 0xf), /* MEM_INST_RETIRED.SPLIT_STORES */
1097+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x81d0, 0xf), /* MEM_INST_RETIRED.ALL_LOADS */
1098+
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x82d0, 0xf), /* MEM_INST_RETIRED.ALL_STORES */
1099+
1100+
INTEL_FLAGS_EVENT_CONSTRAINT_DATALA_LD_RANGE(0xd1, 0xd4, 0xf),
1101+
1102+
INTEL_FLAGS_EVENT_CONSTRAINT(0xd0, 0xf),
1103+
1104+
/*
1105+
* Everything else is handled by PMU_FL_PEBS_ALL, because we
1106+
* need the full constraints from the main table.
1107+
*/
1108+
1109+
EVENT_CONSTRAINT_END
1110+
};
1111+
10881112
struct event_constraint *intel_pebs_constraints(struct perf_event *event)
10891113
{
10901114
struct event_constraint *pebs_constraints = hybrid(event->pmu, pebs_constraints);

arch/x86/events/perf_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,8 @@ extern struct event_constraint intel_icl_pebs_event_constraints[];
15691569

15701570
extern struct event_constraint intel_glc_pebs_event_constraints[];
15711571

1572+
extern struct event_constraint intel_lnc_pebs_event_constraints[];
1573+
15721574
struct event_constraint *intel_pebs_constraints(struct perf_event *event);
15731575

15741576
void intel_pmu_pebs_add(struct perf_event *event);

arch/x86/include/asm/perf_event.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ struct x86_pmu_capability {
307307
#define INTEL_PMC_IDX_FIXED_SLOTS (INTEL_PMC_IDX_FIXED + 3)
308308
#define INTEL_PMC_MSK_FIXED_SLOTS (1ULL << INTEL_PMC_IDX_FIXED_SLOTS)
309309

310+
/* TOPDOWN_BAD_SPECULATION.ALL: fixed counter 4 (Atom only) */
311+
/* TOPDOWN_FE_BOUND.ALL: fixed counter 5 (Atom only) */
312+
/* TOPDOWN_RETIRING.ALL: fixed counter 6 (Atom only) */
313+
310314
static inline bool use_fixed_pseudo_encoding(u64 code)
311315
{
312316
return !(code & 0xff);

0 commit comments

Comments
 (0)