Skip to content

Commit 2145e77

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel: Enable PEBS format 5
The new PEBS Record Format 5 is similar to the PEBS Record Format 4. The only difference is the layout of the Counter Reset fields of the PEBS Config Buffer in the DS area. For the PEBS format 4, the Counter Reset fields allocation is for 8 general-purpose counters followed by 4 fixed-function counters. For the PEBS format 5, the Counter Reset fields allocation is for 32 general-purpose counters followed by 16 fixed-function counters. Extend the MAX_PEBS_EVENTS to 32. Add MAX_PEBS_EVENTS_FMT4 for the previous platform. Except for the DS auto-reload code, other places already assume 32 counters. Only check the PEBS_FMT in the DS auto-reload code. Extend the MAX_FIXED_PEBS_EVENTS to 16, which only impacts the size of struct debug_store and some local temporary variables. The size of struct debug_store increases 288B, which is small and should be acceptable. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 58b2ff2 commit 2145e77

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

arch/x86/events/intel/ds.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,10 @@ static void intel_pmu_pebs_via_pt_enable(struct perf_event *event)
12031203
if (hwc->idx >= INTEL_PMC_IDX_FIXED) {
12041204
base = MSR_RELOAD_FIXED_CTR0;
12051205
idx = hwc->idx - INTEL_PMC_IDX_FIXED;
1206-
value = ds->pebs_event_reset[MAX_PEBS_EVENTS + idx];
1206+
if (x86_pmu.intel_cap.pebs_format < 5)
1207+
value = ds->pebs_event_reset[MAX_PEBS_EVENTS_FMT4 + idx];
1208+
else
1209+
value = ds->pebs_event_reset[MAX_PEBS_EVENTS + idx];
12071210
}
12081211
wrmsrl(base + idx, value);
12091212
}
@@ -1232,8 +1235,12 @@ void intel_pmu_pebs_enable(struct perf_event *event)
12321235
}
12331236
}
12341237

1235-
if (idx >= INTEL_PMC_IDX_FIXED)
1236-
idx = MAX_PEBS_EVENTS + (idx - INTEL_PMC_IDX_FIXED);
1238+
if (idx >= INTEL_PMC_IDX_FIXED) {
1239+
if (x86_pmu.intel_cap.pebs_format < 5)
1240+
idx = MAX_PEBS_EVENTS_FMT4 + (idx - INTEL_PMC_IDX_FIXED);
1241+
else
1242+
idx = MAX_PEBS_EVENTS + (idx - INTEL_PMC_IDX_FIXED);
1243+
}
12371244

12381245
/*
12391246
* Use auto-reload if possible to save a MSR write in the PMI.
@@ -2204,6 +2211,7 @@ void __init intel_ds_init(void)
22042211
break;
22052212

22062213
case 4:
2214+
case 5:
22072215
x86_pmu.drain_pebs = intel_pmu_drain_pebs_icl;
22082216
x86_pmu.pebs_record_size = sizeof(struct pebs_basic);
22092217
if (x86_pmu.intel_cap.pebs_baseline) {

arch/x86/include/asm/intel_ds.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#define PEBS_BUFFER_SIZE (PAGE_SIZE << 4)
88

99
/* The maximal number of PEBS events: */
10-
#define MAX_PEBS_EVENTS 8
11-
#define MAX_FIXED_PEBS_EVENTS 4
10+
#define MAX_PEBS_EVENTS_FMT4 8
11+
#define MAX_PEBS_EVENTS 32
12+
#define MAX_FIXED_PEBS_EVENTS 16
1213

1314
/*
1415
* A debug store configuration.

0 commit comments

Comments
 (0)