lkml.org 
[lkml]   [2011]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: [PATCH V4] POWER: perf_event: Skip updating kernel counters if register value shrinks
Date
From
I keep telling Eric that the code below is incorrect
modulo arithimetic...

> +static u64 check_and_compute_delta(u64 prev, u64 val)
> +{
> + u64 delta = (val - prev) & 0xfffffffful;
> +
> + /*
> + * POWER7 can roll back counter values, if the new value is
smaller
> + * than the previous value it will cause the delta and the
counter to
> + * have bogus values unless we rolled a counter over. If a
coutner is
> + * rolled back, it will be smaller, but within 256, which is the
maximum
> + * number of events to rollback at once. If we dectect a
rollback
> + * return 0. This can lead to a small lack of precision in the
> + * counters.
> + */
> + if (prev > val && (prev - val) < 256)
> + delta = 0;
> +
> + return delta;

The code should detect rollback by looking at the value of 'delta'
otherwise there are horrid end effects near 2^32-1.

For instance:
u32 delta = val - prev;
return delta & 0x80000000 ? 0 : delta;


David






\
 
 \ /
  Last update: 2011-04-27 09:43    [W:0.068 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site