[PATCH V3] POWER: perf_event: Skip updating kernel counters ifregister value shrinks
David Laight
David.Laight at ACULAB.COM
Fri Apr 8 18:38:49 EST 2011
> + u64 delta = 0;
...
> + if (((prev & 0x80000000) && !(val & 0x80000000)) || (val >
prev))
> + delta = (val - prev) & 0xfffffffful;
> +
> + return delta;
The above is incorrect modulo arithmetic.
It is probably intended to do:
s32 delta = val - prev;
return delta < 0 ? 0 : delta;
which will just ignore the fact that some counts are rolled back.
More accurate would be:
static u64 val64;
u32 val = read_perf_count();
s32 delta = val - val_64;
if (delta < 0)
return;
val64 += delta;
Which will not double count for rolled back events.
(The low bits of val64 should always match the actual counter.)
David
More information about the Linuxppc-dev
mailing list