Skip to content

Commit 01330d7

Browse files
Andi KleenIngo Molnar
authored andcommitted
perf/x86: Allow zero PEBS status with only single active event
Normally we drop PEBS events with a zero status field. But when there is only a single PEBS event active we can assume the PEBS record is for that event. The PEBS buffer is always flushed when PEBS events are disabled, so there is no risk of mishandling state PEBS records this way. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Link: http://lkml.kernel.org/r/1449177740-5422-2-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 957ea1f commit 01330d7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,18 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
12301230
pebs_status = p->status & cpuc->pebs_enabled;
12311231
pebs_status &= (1ULL << x86_pmu.max_pebs_events) - 1;
12321232

1233+
/*
1234+
* On some CPUs the PEBS status can be zero when PEBS is
1235+
* racing with clearing of GLOBAL_STATUS.
1236+
*
1237+
* Normally we would drop that record, but in the
1238+
* case when there is only a single active PEBS event
1239+
* we can assume it's for that event.
1240+
*/
1241+
if (!pebs_status && cpuc->pebs_enabled &&
1242+
!(cpuc->pebs_enabled & (cpuc->pebs_enabled-1)))
1243+
pebs_status = cpuc->pebs_enabled;
1244+
12331245
bit = find_first_bit((unsigned long *)&pebs_status,
12341246
x86_pmu.max_pebs_events);
12351247
if (bit >= x86_pmu.max_pebs_events)

0 commit comments

Comments
 (0)