perf, x86: Fix PEBS enable/disable vs cpuc->enabled
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Sat, 6 Mar 2010 12:47:07 +0000 (13:47 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 10 Mar 2010 12:23:36 +0000 (13:23 +0100)
We should never call ->enable with the pmu enabled, and we _can_ have
->disable called with the pmu enabled.

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

index 66c6962..9ad0e67 100644 (file)
@@ -338,7 +338,7 @@ static void intel_pmu_pebs_enable(struct perf_event *event)
        hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
 
        val |= 1ULL << hwc->idx;
-       wrmsrl(MSR_IA32_PEBS_ENABLE, val);
+       WARN_ON_ONCE(cpuc->enabled);
 
        if (x86_pmu.intel_cap.pebs_trap)
                intel_pmu_lbr_enable(event);
@@ -351,7 +351,8 @@ static void intel_pmu_pebs_disable(struct perf_event *event)
        u64 val = cpuc->pebs_enabled;
 
        val &= ~(1ULL << hwc->idx);
-       wrmsrl(MSR_IA32_PEBS_ENABLE, val);
+       if (cpuc->enabled)
+               wrmsrl(MSR_IA32_PEBS_ENABLE, val);
 
        hwc->config |= ARCH_PERFMON_EVENTSEL_INT;