From: Robert Richter Date: Mon, 2 Apr 2012 18:19:14 +0000 (+0200) Subject: perf/x86-ibs: Trigger overflow if remaining period is too small X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc006cf7cc7471e1bdf34e40111971e03622af6c;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git perf/x86-ibs: Trigger overflow if remaining period is too small There are cases where the remaining period is smaller than the minimal possible value. In this case the counter is restarted with the minimal period. This is of no use as the interrupt handler will trigger immediately again and most likely hits itself. This biases the results. So, if the remaining period is within the min range, we better do not restart the counter and instead trigger the overflow. Signed-off-by: Robert Richter Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1333390758-10893-9-git-send-email-robert.richter@amd.com Signed-off-by: Ingo Molnar --- diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c index 29a1bffe1df..3e32908292a 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c +++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c @@ -78,16 +78,13 @@ perf_event_set_period(struct hw_perf_event *hwc, u64 min, u64 max, u64 *hw_perio overflow = 1; } - if (unlikely(left <= 0)) { + if (unlikely(left < (s64)min)) { left += period; local64_set(&hwc->period_left, left); hwc->last_period = period; overflow = 1; } - if (unlikely(left < min)) - left = min; - if (left > max) left = max;