metag: perf: fix wrap handling in delta calculation
authorJames Hogan <[email protected]>
Wed, 27 Feb 2013 16:16:38 +0000 (16:16 +0000)
committerJames Hogan <[email protected]>
Fri, 15 Mar 2013 13:19:54 +0000 (13:19 +0000)
When calculating the delta, mask with MAX_PERIOD (24 bits) to handle
wrapping, which particularly happens with periodic sampling since the
value is intentionally set so that it will overflow soon.

Signed-off-by: James Hogan <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
arch/metag/kernel/perf/perf_event.c

index f38bf6d4dc55bb039d7f7b5cc8e3cda82190812f..8096db2a550b812ed3aa6daf37fd347cd9aa2861 100644 (file)
@@ -211,7 +211,7 @@ again:
        /*
         * Calculate the delta and add it to the counter.
         */
-       delta = new_raw_count - prev_raw_count;
+       delta = (new_raw_count - prev_raw_count) & MAX_PERIOD;
 
        local64_add(delta, &event->count);
 }