powerpc/perf: Add an explict flag indicating presence of SLOT field
authorMichael Ellerman <michael@ellerman.id.au>
Thu, 25 Apr 2013 19:28:23 +0000 (19:28 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 26 Apr 2013 06:11:07 +0000 (16:11 +1000)
In perf_ip_adjust() we potentially use the MMCRA[SLOT] field to adjust
the reported IP of a sampled instruction.

Currently the logic is written so that if the backend does NOT have
the PPMU_ALT_SIPR flag set then we assume MMCRA[SLOT] exists.

However on power8 we do not want to set ALT_SIPR (it's in a third
location), and we also do not have MMCRA[SLOT].

So add a new flag which only indicates whether MMCRA[SLOT] exists.

Naively we'd set it on everything except power6/7, because they set
ALT_SIPR, and we've reversed the polarity of the flag. But it's more
complicated than that.

mpc7450 is 32-bit, and uses its own version of perf_ip_adjust()
which doesn't use MMCRA[SLOT], so it doesn't need the new flag set and
the behaviour is unchanged.

PPC970 (and I assume power4) don't have MMCRA[SLOT], so shouldn't have
the new flag set. This is a behaviour change on those cpus, though we
were probably getting lucky and the bits in question were 0.

power5 and power5+ set the new flag, behaviour unchanged.

power6 & power7 do not set the new flag, behaviour unchanged.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/perf_event_server.h
arch/powerpc/perf/core-book3s.c
arch/powerpc/perf/power5+-pmu.c
arch/powerpc/perf/power5-pmu.c

index d0aec72722e945f5ac00c82047cef4a7257622bc..7074aeccb9f9ce9711296d65248a88d47b3c8e8d 100644 (file)
@@ -52,6 +52,7 @@ struct power_pmu {
 #define PPMU_NO_SIPR           0x00000004 /* no SIPR/HV in MMCRA at all */
 #define PPMU_NO_CONT_SAMPLING  0x00000008 /* no continuous sampling */
 #define PPMU_SIAR_VALID                0x00000010 /* Processor has SIAR Valid bit */
+#define PPMU_HAS_SSLOT         0x00000020 /* Has sampled slot in MMCRA */
 
 /*
  * Values for flags to get_alternatives()
index 65362e98eb263cdf84ad61bb7f154598c9c5e3a4..eb644806f00e3dc243b6b0a0cba3eca4fd6e6387 100644 (file)
@@ -98,11 +98,12 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
 {
        unsigned long mmcra = regs->dsisr;
 
-       if ((mmcra & MMCRA_SAMPLE_ENABLE) && !(ppmu->flags & PPMU_ALT_SIPR)) {
+       if ((ppmu->flags & PPMU_HAS_SSLOT) && (mmcra & MMCRA_SAMPLE_ENABLE)) {
                unsigned long slot = (mmcra & MMCRA_SLOT) >> MMCRA_SLOT_SHIFT;
                if (slot > 1)
                        return 4 * (slot - 1);
        }
+
        return 0;
 }
 
index a8757baa28f34690a7e3b9b033569da86954529c..b03b6dc0172d8c2cf3a0c91713edddbb34be2a7c 100644 (file)
@@ -671,7 +671,7 @@ static struct power_pmu power5p_pmu = {
        .get_alternatives       = power5p_get_alternatives,
        .disable_pmc            = power5p_disable_pmc,
        .limited_pmc_event      = power5p_limited_pmc_event,
-       .flags                  = PPMU_LIMITED_PMC5_6,
+       .flags                  = PPMU_LIMITED_PMC5_6 | PPMU_HAS_SSLOT,
        .n_generic              = ARRAY_SIZE(power5p_generic_events),
        .generic_events         = power5p_generic_events,
        .cache_events           = &power5p_cache_events,
index e7f06eb7a861b3c47113b52ded65348912e20bca..1e8ce423c3af0b39b031e82094da116426f8bb78 100644 (file)
@@ -615,6 +615,7 @@ static struct power_pmu power5_pmu = {
        .n_generic              = ARRAY_SIZE(power5_generic_events),
        .generic_events         = power5_generic_events,
        .cache_events           = &power5_cache_events,
+       .flags                  = PPMU_HAS_SSLOT,
 };
 
 static int __init init_power5_pmu(void)