Re: [PATCH 4/4] perf/x86/intel: drain PEBS buffer in event read

From: Liang, Kan
Date: Tue Dec 19 2017 - 15:10:11 EST




On 12/19/2017 2:02 PM, Peter Zijlstra wrote:
On Mon, Dec 18, 2017 at 03:34:51AM -0800, kan.liang@xxxxxxxxxxxxxxx wrote:
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -926,6 +926,16 @@ void intel_pmu_pebs_del(struct perf_event *event)
pebs_update_state(needed_cb, cpuc, event->ctx->pmu);
}
+void intel_pmu_pebs_read(struct perf_event *event)
+{
+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
+
+ if (pebs_needs_sched_cb(cpuc))
+ return intel_pmu_drain_pebs_buffer();
+
+ x86_perf_event_update(event, 0, 0);
+}

This is completely broken.. what if @event isn't a pebs event, but we
do have an auto-reloading pebs event configured?


precise_ip will be checked before intel_pmu_pebs_read is called.
So @event must be a pebs event.

@@ -2060,6 +2060,14 @@ static void intel_pmu_del_event(struct perf_event *event)
intel_pmu_pebs_del(event);
}

+static void intel_pmu_read_event(struct perf_event *event)
+{
+ if (event->attr.precise_ip)
+ return intel_pmu_pebs_read(event);
+
+ x86_perf_event_update(event, 0, 0);
+}