powerpc/perf: Don't enable if we have zero events
authorMichael Ellerman <michael@ellerman.id.au>
Fri, 28 Jun 2013 08:15:14 +0000 (18:15 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2013 21:07:22 +0000 (14:07 -0700)
commit 4ea355b5368bde0574c12430df53334c4be3bdcf upstream.

In power_pmu_enable() we still enable the PMU even if we have zero
events. This should have no effect but doesn't make much sense. Instead
just return after telling the hypervisor that we are not using the PMCs.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/perf/core-book3s.c

index af4b4b1a691f01bdacb2beaae56659e36393562b..d3ee2e50a3a6fbc44bac15c9fb5ec4dfff889867 100644 (file)
@@ -926,6 +926,11 @@ static void power_pmu_enable(struct pmu *pmu)
        if (!cpuhw->disabled)
                goto out;
 
+       if (cpuhw->n_events == 0) {
+               ppc_set_pmu_inuse(0);
+               goto out;
+       }
+
        cpuhw->disabled = 0;
 
        /*
@@ -937,8 +942,6 @@ static void power_pmu_enable(struct pmu *pmu)
        if (!cpuhw->n_added) {
                mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);
                mtspr(SPRN_MMCR1, cpuhw->mmcr[1]);
-               if (cpuhw->n_events == 0)
-                       ppc_set_pmu_inuse(0);
                goto out_enable;
        }