powerpc/perf_event: Skip updating kernel counters if register value shrinks
commitfae123f8208d7d56b35c0c8e9a299e052f62dfcc
authorEric B Munson <emunson@mgebm.net>
Fri, 15 Apr 2011 08:12:30 +0000 (15 08:12 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 21 Apr 2011 21:32:54 +0000 (21 14:32 -0700)
tree2006476f796d44cfde22fb53ad562f3a193418d2
parent4efa7d8da6914e9cce94f405649e407ffa20a04e
powerpc/perf_event: Skip updating kernel counters if register value shrinks

commit 86c74ab317c1ef4d37325e0d7ca8a01a796b0bd7 upstream.

Because of speculative event roll back, it is possible for some event coutners
to decrease between reads on POWER7.  This causes a problem with the way that
counters are updated.  Delta calues are calculated in a 64 bit value and the
top 32 bits are masked.  If the register value has decreased, this leaves us
with a very large positive value added to the kernel counters.  This patch
protects against this by skipping the update if the delta would be negative.
This can lead to a lack of precision in the coutner values, but from my testing
the value is typcially fewer than 10 samples at a time.

Signed-off-by: Eric B Munson <emunson@mgebm.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/powerpc/kernel/perf_event.c