linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf, x86: P4 PMU -- Fix unflagged overflows test
@ 2011-02-04 12:17 Cyrill Gorcunov
  2011-02-04 16:59 ` Don Zickus
  2011-02-05  2:28 ` George Spelvin
  0 siblings, 2 replies; 11+ messages in thread
From: Cyrill Gorcunov @ 2011-02-04 12:17 UTC (permalink / raw)
  To: Ingo Molnar, Don Zickus
  Cc: George Spelvin, Meelis Roos, Lin Ming, Peter Zijlstra, lkml

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]

Please apply it, sorry for non-inlined patch (have a web access only at moment).

Note that I've tested the patch on non-HT machine so if someone have HT'ed one
-- it would be great to test the patch there.

Cyrill

[-- Attachment #2: x86-perf-unflagged-nmi --]
[-- Type: application/octet-stream, Size: 2023 bytes --]

From: Cyrill Gorcunov <gorcunov@openvz.org>
Subject: [PATCH] perf, x86: P4 PMU -- Fix unflagged overflows test

A couple of people have reported an unknown NMI issue on p4 pmu.
This patch should fix it.

Reported-by: George Spelvin <linux@horizon.com>
Reported-by: Meelis Roos <mroos@linux.ee>
Reported-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: Lin Ming <ming.m.lin@intel.com>
CC: Don Zickus <dzickus@redhat.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 arch/x86/include/asm/perf_event_p4.h |    1 +
 arch/x86/kernel/cpu/perf_event_p4.c  |   11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

Index: linux-2.6.tip/arch/x86/include/asm/perf_event_p4.h
===================================================================
--- linux-2.6.tip.orig/arch/x86/include/asm/perf_event_p4.h
+++ linux-2.6.tip/arch/x86/include/asm/perf_event_p4.h
@@ -22,6 +22,7 @@
 
 #define ARCH_P4_CNTRVAL_BITS	(40)
 #define ARCH_P4_CNTRVAL_MASK	((1ULL << ARCH_P4_CNTRVAL_BITS) - 1)
+#define ARCH_P4_UNFLAGGED_BIT	((1ULL) << (ARCH_P4_CNTRVAL_BITS - 1))
 
 #define P4_ESCR_EVENT_MASK	0x7e000000U
 #define P4_ESCR_EVENT_SHIFT	25
Index: linux-2.6.tip/arch/x86/kernel/cpu/perf_event_p4.c
===================================================================
--- linux-2.6.tip.orig/arch/x86/kernel/cpu/perf_event_p4.c
+++ linux-2.6.tip/arch/x86/kernel/cpu/perf_event_p4.c
@@ -770,9 +770,14 @@ static inline int p4_pmu_clear_cccr_ovf(
 		return 1;
 	}
 
-	/* it might be unflagged overflow */
-	rdmsrl(hwc->event_base + hwc->idx, v);
-	if (!(v & ARCH_P4_CNTRVAL_MASK))
+	/*
+	 * at some circumstances the overflow might issue NMI but did
+	 * not set P4_CCCR_OVF bit so since a counter holds a negative value
+	 * we simply check for high bit being set, if it's cleared it means
+	 * the counter has reached zero value and continued counting before
+	 * real NMI signal was received
+	 */
+	if (!(v & ARCH_P4_UNFLAGGED_BIT))
 		return 1;
 
 	return 0;

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-02-08 14:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 12:17 [PATCH] perf, x86: P4 PMU -- Fix unflagged overflows test Cyrill Gorcunov
2011-02-04 16:59 ` Don Zickus
2011-02-04 17:32   ` Cyrill Gorcunov
2011-02-06 19:21   ` Cyrill Gorcunov
2011-02-07 17:22     ` Cyrill Gorcunov
2011-02-08 14:26       ` George Spelvin
2011-02-08 14:38         ` Cyrill Gorcunov
2011-02-05  2:28 ` George Spelvin
2011-02-05  8:40   ` Cyrill Gorcunov
2011-02-05  9:15     ` George Spelvin
2011-02-05  9:22       ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).