metag: perf: fix wrap handling in delta calculation
authorJames Hogan <james.hogan@imgtec.com>
Wed, 27 Feb 2013 16:16:38 +0000 (16:16 +0000)
committerJames Hogan <james.hogan@imgtec.com>
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 <james.hogan@imgtec.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
arch/metag/kernel/perf/perf_event.c

index f38bf6d..8096db2 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);
 }