perf, x86: Fixup the PEBS handler for Core2 cpus

Previous thread: perf: Some perf-kvm documentation edits by Linux Kernel Mailing List on Tuesday, May 18, 2010 - 10:01 am. (1 message)

Next thread: perf probe: Fix to exit callback soon after finding too many probe points by Linux Kernel Mailing List on Tuesday, May 18, 2010 - 10:01 am. (1 message)
From: Linux Kernel Mailing List
Date: Tuesday, May 18, 2010 - 9:59 am

Gitweb:     http://git.kernel.org/linus/d80c7502ff63aa0d99d8c0c5803d28bbef67a74e
Commit:     d80c7502ff63aa0d99d8c0c5803d28bbef67a74e
Parent:     7645a24cbd01cbf4865d1273d5ddaa8d8c2ccb3a
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Tue Mar 9 11:41:02 2010 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed Mar 10 13:23:39 2010 +0100

    perf, x86: Fixup the PEBS handler for Core2 cpus
    
    Pull the core handler in line with the nhm one, also make sure we always
    drain the buffer.
    
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
    Cc: paulus@samba.org
    Cc: eranian@google.com
    Cc: robert.richter@amd.com
    Cc: fweisbec@gmail.com
    LKML-Reference: <new-submission>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/cpu/perf_event_intel_ds.c |   38 ++++++++++++++++++----------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 2423694..1bfd59b 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -472,20 +472,39 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
 	struct pt_regs regs;
 	int n;
 
-	if (!event || !ds || !x86_pmu.pebs)
+	if (!ds || !x86_pmu.pebs)
 		return;
 
 	at  = (struct pebs_record_core *)(unsigned long)ds->pebs_buffer_base;
 	top = (struct pebs_record_core *)(unsigned long)ds->pebs_index;
 
-	if (top <= at)
+	/*
+	 * Whatever else happens, drain the thing
+	 */
+	ds->pebs_index = ds->pebs_buffer_base;
+
+	if (!test_bit(0, cpuc->active_mask))
 		return;
 
-	ds->pebs_index = ds->pebs_buffer_base;
+	WARN_ON_ONCE(!event);
+
+	if (!event->attr.precise)
+		return;
+
+	n = top - at;
+	if (n <= 0)
+		return;
 
 	if (!intel_pmu_save_and_restart(event))
 		return;
 
+	/*
+	 * Should not happen, we program the threshold at 1 and do not
+	 * ...
Previous thread: perf: Some perf-kvm documentation edits by Linux Kernel Mailing List on Tuesday, May 18, 2010 - 10:01 am. (1 message)

Next thread: perf probe: Fix to exit callback soon after finding too many probe points by Linux Kernel Mailing List on Tuesday, May 18, 2010 - 10:01 am. (1 message)