Skip to content

Commit a3d8654

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf/x86/intel/pebs: Add PEBSv3 decoding
PEBSv3 as present on Skylake fixed the long standing issue of the status bits. They now really reflect the events that generated the record. Tested-by: Andi Kleen <[email protected]> Tested-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andrew Morton <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent c4937a9 commit a3d8654

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,9 @@ get_next_pebs_record_by_bit(void *base, void *top, int bit)
10341034
struct pebs_record_nhm *p = at;
10351035

10361036
if (test_bit(bit, (unsigned long *)&p->status)) {
1037+
/* PEBS v3 has accurate status bits */
1038+
if (x86_pmu.intel_cap.pebs_format >= 3)
1039+
return at;
10371040

10381041
if (p->status == (1 << bit))
10391042
return at;
@@ -1055,20 +1058,18 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
10551058
{
10561059
struct perf_sample_data data;
10571060
struct pt_regs regs;
1058-
int i;
10591061
void *at = get_next_pebs_record_by_bit(base, top, bit);
10601062

10611063
if (!intel_pmu_save_and_restart(event) &&
10621064
!(event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD))
10631065
return;
10641066

1065-
if (count > 1) {
1066-
for (i = 0; i < count - 1; i++) {
1067-
setup_pebs_sample_data(event, iregs, at, &data, &regs);
1068-
perf_event_output(event, &data, &regs);
1069-
at += x86_pmu.pebs_record_size;
1070-
at = get_next_pebs_record_by_bit(at, top, bit);
1071-
}
1067+
while (count > 1) {
1068+
setup_pebs_sample_data(event, iregs, at, &data, &regs);
1069+
perf_event_output(event, &data, &regs);
1070+
at += x86_pmu.pebs_record_size;
1071+
at = get_next_pebs_record_by_bit(at, top, bit);
1072+
count--;
10721073
}
10731074

10741075
setup_pebs_sample_data(event, iregs, at, &data, &regs);
@@ -1124,9 +1125,9 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
11241125
struct debug_store *ds = cpuc->ds;
11251126
struct perf_event *event;
11261127
void *base, *at, *top;
1127-
int bit;
11281128
short counts[MAX_PEBS_EVENTS] = {};
11291129
short error[MAX_PEBS_EVENTS] = {};
1130+
int bit, i;
11301131

11311132
if (!x86_pmu.pebs_active)
11321133
return;
@@ -1142,6 +1143,15 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
11421143
for (at = base; at < top; at += x86_pmu.pebs_record_size) {
11431144
struct pebs_record_nhm *p = at;
11441145

1146+
/* PEBS v3 has accurate status bits */
1147+
if (x86_pmu.intel_cap.pebs_format >= 3) {
1148+
for_each_set_bit(bit, (unsigned long *)&p->status,
1149+
MAX_PEBS_EVENTS)
1150+
counts[bit]++;
1151+
1152+
continue;
1153+
}
1154+
11451155
bit = find_first_bit((unsigned long *)&p->status,
11461156
x86_pmu.max_pebs_events);
11471157
if (bit >= x86_pmu.max_pebs_events)
@@ -1171,8 +1181,6 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
11711181
pebs_status = p->status & cpuc->pebs_enabled;
11721182
pebs_status &= (1ULL << MAX_PEBS_EVENTS) - 1;
11731183
if (pebs_status != (1 << bit)) {
1174-
u8 i;
1175-
11761184
for_each_set_bit(i, (unsigned long *)&pebs_status,
11771185
MAX_PEBS_EVENTS)
11781186
error[i]++;

0 commit comments

Comments
 (0)