Skip to content

Commit

Permalink
metag: perf: fix wrap handling in delta calculation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
James Hogan committed Mar 15, 2013
1 parent 3424dab commit c43ca04
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/metag/kernel/perf/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void metag_pmu_event_update(struct perf_event *event,
/*
* 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);
}
Expand Down

0 comments on commit c43ca04

Please sign in to comment.