public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/x86: fix uncore PCI fixed counter handling
@ 2013-09-09 19:53 Stephane Eranian
  2013-09-10 20:22 ` Andi Kleen
  2013-09-12 11:11 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2013-09-09 19:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: peterz, mingo, zheng.z.yan, ak


There was a bug in the handling of SNB-EP/IVB-EP uncore PCI
fixed counters, e.g., IMC. It would cause erratic values to
be returned for the IMC clockticks event. This was due to
a bogus hwc->config value which was then written to PCI
config space. The fixed counter has most fields marked as
reserved with hw reset values of 0. Yet the kernel was
defaulting to a hwc->config = ~0 and that was causing
the issues. The patch sets the hwc->config values for fixed
uncore event to 0. Now, the values of imc clockticks is
correct.
    
$ perf stat -a -C 0 -e uncore_imc_0/clockticks/ -I 1000 sleep 10
    
Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index f14d9df..dfb4aa54 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -2707,7 +2707,7 @@ uncore_get_event_constraint(struct intel_uncore_box *box, struct perf_event *eve
 			return c;
 	}
 
-	if (event->hw.config == ~0ULL)
+	if (event->attr.config == UNCORE_FIXED_EVENT)
 		return &constraint_fixed;
 
 	if (type->constraints) {
@@ -3011,7 +3011,9 @@ static int uncore_pmu_event_init(struct perf_event *event)
 		 */
 		if (pmu->type->single_fixed && pmu->pmu_idx > 0)
 			return -EINVAL;
-		hwc->config = ~0ULL;
+
+		/* fixed counters have event field hardcoded to zero */
+		hwc->config = 0ULL;
 	} else {
 		hwc->config = event->attr.config & pmu->type->event_mask;
 		if (pmu->type->ops->hw_config) {

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

end of thread, other threads:[~2013-09-12 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-09 19:53 [PATCH] perf/x86: fix uncore PCI fixed counter handling Stephane Eranian
2013-09-10 20:22 ` Andi Kleen
2013-09-12 11:11 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox