perf_counter: fix fixed-purpose counter support on v2 Intel-PERFMON
authorIngo Molnar <mingo@elte.hu>
Mon, 4 May 2009 17:04:09 +0000 (19:04 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 4 May 2009 18:17:31 +0000 (20:17 +0200)
Fixed-purpose counters stopped working in a simple 'perf stat ls' run:

   <not counted>  cache references
   <not counted>  cache misses

Due to:

  ef7b3e0: perf_counter, x86: remove vendor check in fixed_mode_idx()

Which made x86_pmu.num_counters_fixed matter: if it's nonzero, the
fixed-purpose counters are utilized.

But on v2 perfmon this field is not set (despite there being
fixed-purpose PMCs). So add a quirk to set the number of fixed-purpose
counters to at least three.

[ Impact: add quirk for three fixed-purpose counters on certain Intel CPUs ]

Cc: Robert Richter <robert.richter@amd.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1241002046-8832-28-git-send-email-robert.richter@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/cpu/perf_counter.c

index 196b58f044483d1f1ac60dee643b4a250bb8be5c..a6878b0798e5b300e537bf0649edaa4aaddd6516 100644 (file)
@@ -962,7 +962,13 @@ static int intel_pmu_init(void)
        x86_pmu = intel_pmu;
        x86_pmu.version = version;
        x86_pmu.num_counters = eax.split.num_counters;
-       x86_pmu.num_counters_fixed = edx.split.num_counters_fixed;
+
+       /*
+        * Quirk: v2 perfmon does not report fixed-purpose counters, so
+        * assume at least 3 counters:
+        */
+       x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
+
        x86_pmu.counter_bits = eax.split.bit_width;
        x86_pmu.counter_mask = (1ULL << eax.split.bit_width) - 1;