lkml.org 
[lkml]   [2010]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] perf: fix possible divide-by-zero in perf_swevent_overflow()
From
Date
On Thu, 2010-08-26 at 20:07 +0800, Dongdong Deng wrote:
> The event->hw.last_period is possible to zero, thus it will
> cause divide_by_zero later in perf_swevent_set_period().

How can it be zero?

> This patch checks event->hw.last_period before invoke
> perf_swevent_set_period() and replaces "event->hw" with "hwc".
>
> Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Paul Mackerras <paulus@samba.org>
> ---
> kernel/perf_event.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 403d180..ccba741 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -4050,8 +4050,8 @@ static void perf_swevent_overflow(struct perf_event *event, u64 overflow,
> struct hw_perf_event *hwc = &event->hw;
> int throttle = 0;
>
> - data->period = event->hw.last_period;
> - if (!overflow)
> + data->period = hwc->last_period;
> + if (!overflow && hwc->last_period)
> overflow = perf_swevent_set_period(event);
>
> if (hwc->interrupts == MAX_INTERRUPTS)




\
 
 \ /
  Last update: 2010-08-26 14:15    [W:0.403 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site