powerpc/perf_event: Skip updating kernel counters if register value shrinks
authorEric B Munson <emunson@mgebm.net>
Fri, 15 Apr 2011 08:12:30 +0000 (08:12 +0000)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:42:25 +0000 (11:42 -0700)
commit05dfd0c2c5fb53bccc86f7da2d3ddc703b40ebc7
treee38ef241bedfc71153eda74da6fad9d3fb3acdff
parent42063ff263065b99516f9faf2479993c9301de29
powerpc/perf_event: Skip updating kernel counters if register value shrinks

BugLink: http://bugs.launchpad.net/bugs/769042

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>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
arch/powerpc/kernel/perf_event.c