From: Peter Zijlstra <peterz@infradead.org>
To: Dongdong Deng <dongdong.deng@windriver.com>
Cc: mingo@elte.hu, fweisbec@gmail.com, acme@redhat.com,
paulus@samba.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: fix possible divide-by-zero in perf_swevent_overflow()
Date: Thu, 26 Aug 2010 14:12:07 +0200 [thread overview]
Message-ID: <1282824727.1975.747.camel@laptop> (raw)
In-Reply-To: <1282824438-13970-1-git-send-email-dongdong.deng@windriver.com>
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)
next prev parent reply other threads:[~2010-08-26 12:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 12:07 [PATCH] perf: fix possible divide-by-zero in perf_swevent_overflow() Dongdong Deng
2010-08-26 12:12 ` Peter Zijlstra [this message]
2010-08-26 12:36 ` DDD
2010-08-26 12:58 ` Peter Zijlstra
2010-08-27 12:21 ` DDD
2010-08-27 12:50 ` Peter Zijlstra
2010-08-27 13:19 ` DDD
2010-08-27 13:37 ` Frederic Weisbecker
2010-10-25 5:58 ` DDD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282824727.1975.747.camel@laptop \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=dongdong.deng@windriver.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox