Skip to content

Commit ccf170e

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel: Fix PEBS data source encoding for ADL
The PEBS data source encoding for the e-core is different from the p-core. Add the pebs_data_source[] in the struct x86_hybrid_pmu to store the data source encoding for each type of the core. Add intel_pmu_pebs_data_source_grt() for the e-core. There is nothing changed for the data source encoding of the p-core, which still reuse the intel_pmu_pebs_data_source_skl(). Fixes: f83d2f9 ("perf/x86/intel: Add Alder Lake Hybrid support") 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> Link: https://lkml.kernel.org/r/20220629150840.2235741-2-kan.liang@linux.intel.com
1 parent 39a4127 commit ccf170e

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

arch/x86/events/intel/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6241,7 +6241,7 @@ __init int intel_pmu_init(void)
62416241
x86_pmu.flags |= PMU_FL_INSTR_LATENCY;
62426242
x86_pmu.flags |= PMU_FL_MEM_LOADS_AUX;
62436243
x86_pmu.lbr_pt_coexist = true;
6244-
intel_pmu_pebs_data_source_skl(false);
6244+
intel_pmu_pebs_data_source_adl();
62456245
x86_pmu.pebs_latency_data = adl_latency_data_small;
62466246
x86_pmu.num_topdown_events = 8;
62476247
x86_pmu.update_topdown_event = adl_update_topdown_event;

arch/x86/events/intel/ds.c

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,40 @@ void __init intel_pmu_pebs_data_source_nhm(void)
9494
pebs_data_source[0x07] = OP_LH | P(LVL, L3) | LEVEL(L3) | P(SNOOP, HITM);
9595
}
9696

97-
void __init intel_pmu_pebs_data_source_skl(bool pmem)
97+
static void __init __intel_pmu_pebs_data_source_skl(bool pmem, u64 *data_source)
9898
{
9999
u64 pmem_or_l4 = pmem ? LEVEL(PMEM) : LEVEL(L4);
100100

101-
pebs_data_source[0x08] = OP_LH | pmem_or_l4 | P(SNOOP, HIT);
102-
pebs_data_source[0x09] = OP_LH | pmem_or_l4 | REM | P(SNOOP, HIT);
103-
pebs_data_source[0x0b] = OP_LH | LEVEL(RAM) | REM | P(SNOOP, NONE);
104-
pebs_data_source[0x0c] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOPX, FWD);
105-
pebs_data_source[0x0d] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOP, HITM);
101+
data_source[0x08] = OP_LH | pmem_or_l4 | P(SNOOP, HIT);
102+
data_source[0x09] = OP_LH | pmem_or_l4 | REM | P(SNOOP, HIT);
103+
data_source[0x0b] = OP_LH | LEVEL(RAM) | REM | P(SNOOP, NONE);
104+
data_source[0x0c] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOPX, FWD);
105+
data_source[0x0d] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOP, HITM);
106+
}
107+
108+
void __init intel_pmu_pebs_data_source_skl(bool pmem)
109+
{
110+
__intel_pmu_pebs_data_source_skl(pmem, pebs_data_source);
111+
}
112+
113+
static void __init intel_pmu_pebs_data_source_grt(u64 *data_source)
114+
{
115+
data_source[0x05] = OP_LH | P(LVL, L3) | LEVEL(L3) | P(SNOOP, HIT);
116+
data_source[0x06] = OP_LH | P(LVL, L3) | LEVEL(L3) | P(SNOOP, HITM);
117+
data_source[0x08] = OP_LH | P(LVL, L3) | LEVEL(L3) | P(SNOOPX, FWD);
118+
}
119+
120+
void __init intel_pmu_pebs_data_source_adl(void)
121+
{
122+
u64 *data_source;
123+
124+
data_source = x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX].pebs_data_source;
125+
memcpy(data_source, pebs_data_source, sizeof(pebs_data_source));
126+
__intel_pmu_pebs_data_source_skl(false, data_source);
127+
128+
data_source = x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX].pebs_data_source;
129+
memcpy(data_source, pebs_data_source, sizeof(pebs_data_source));
130+
intel_pmu_pebs_data_source_grt(data_source);
106131
}
107132

108133
static u64 precise_store_data(u64 status)
@@ -198,7 +223,7 @@ u64 adl_latency_data_small(struct perf_event *event, u64 status)
198223

199224
dse.val = status;
200225

201-
val = pebs_data_source[dse.ld_dse];
226+
val = hybrid_var(event->pmu, pebs_data_source)[dse.ld_dse];
202227

203228
/*
204229
* For the atom core on ADL,
@@ -214,7 +239,7 @@ u64 adl_latency_data_small(struct perf_event *event, u64 status)
214239
return val;
215240
}
216241

217-
static u64 load_latency_data(u64 status)
242+
static u64 load_latency_data(struct perf_event *event, u64 status)
218243
{
219244
union intel_x86_pebs_dse dse;
220245
u64 val;
@@ -224,7 +249,7 @@ static u64 load_latency_data(u64 status)
224249
/*
225250
* use the mapping table for bit 0-3
226251
*/
227-
val = pebs_data_source[dse.ld_dse];
252+
val = hybrid_var(event->pmu, pebs_data_source)[dse.ld_dse];
228253

229254
/*
230255
* Nehalem models do not support TLB, Lock infos
@@ -263,7 +288,7 @@ static u64 load_latency_data(u64 status)
263288
return val;
264289
}
265290

266-
static u64 store_latency_data(u64 status)
291+
static u64 store_latency_data(struct perf_event *event, u64 status)
267292
{
268293
union intel_x86_pebs_dse dse;
269294
u64 val;
@@ -273,7 +298,7 @@ static u64 store_latency_data(u64 status)
273298
/*
274299
* use the mapping table for bit 0-3
275300
*/
276-
val = pebs_data_source[dse.st_lat_dse];
301+
val = hybrid_var(event->pmu, pebs_data_source)[dse.st_lat_dse];
277302

278303
pebs_set_tlb_lock(&val, dse.st_lat_stlb_miss, dse.st_lat_locked);
279304

@@ -1459,9 +1484,9 @@ static u64 get_data_src(struct perf_event *event, u64 aux)
14591484
bool fst = fl & (PERF_X86_EVENT_PEBS_ST | PERF_X86_EVENT_PEBS_HSW_PREC);
14601485

14611486
if (fl & PERF_X86_EVENT_PEBS_LDLAT)
1462-
val = load_latency_data(aux);
1487+
val = load_latency_data(event, aux);
14631488
else if (fl & PERF_X86_EVENT_PEBS_STLAT)
1464-
val = store_latency_data(aux);
1489+
val = store_latency_data(event, aux);
14651490
else if (fl & PERF_X86_EVENT_PEBS_LAT_HYBRID)
14661491
val = x86_pmu.pebs_latency_data(event, aux);
14671492
else if (fst && (fl & PERF_X86_EVENT_PEBS_HSW_PREC))

arch/x86/events/perf_event.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ enum {
644644
x86_lbr_exclusive_max,
645645
};
646646

647+
#define PERF_PEBS_DATA_SOURCE_MAX 0x10
648+
647649
struct x86_hybrid_pmu {
648650
struct pmu pmu;
649651
const char *name;
@@ -671,6 +673,8 @@ struct x86_hybrid_pmu {
671673
unsigned int late_ack :1,
672674
mid_ack :1,
673675
enabled_ack :1;
676+
677+
u64 pebs_data_source[PERF_PEBS_DATA_SOURCE_MAX];
674678
};
675679

676680
static __always_inline struct x86_hybrid_pmu *hybrid_pmu(struct pmu *pmu)
@@ -1508,6 +1512,8 @@ void intel_pmu_pebs_data_source_nhm(void);
15081512

15091513
void intel_pmu_pebs_data_source_skl(bool pmem);
15101514

1515+
void intel_pmu_pebs_data_source_adl(void);
1516+
15111517
int intel_pmu_setup_lbr_filter(struct perf_event *event);
15121518

15131519
void intel_pt_interrupt(void);

0 commit comments

Comments
 (0)