public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: DDD <dongdong.deng@windriver.com>
To: Peter Zijlstra <peterz@infradead.org>
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: Fri, 27 Aug 2010 20:21:21 +0800	[thread overview]
Message-ID: <4C77ADC1.5030502@windriver.com> (raw)
In-Reply-To: <1282827486.1975.845.camel@laptop>

Peter Zijlstra wrote:
> On Thu, 2010-08-26 at 20:36 +0800, DDD wrote:
>> Peter Zijlstra wrote:
>>> 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?
>> When I am running the kgdbts to test the hw_breakpoint_layer with kgdb,
>> I get a call trace as following and this problem is hardly to reproduce.
>>
>> Maybe the root cause was from kgdb/hw_breakpoint_layer,
> 
> Yeah, I think there's a bug in the hw_breakpoint stuff, does something
> like the below fix it?

hello Peter,

Thanks for your patch, but I still could reproduce the problem with your 
patch.


Thanks,
Dongdong




> 
> 
>> but add a checking is good to us and harmless. :-)
> 
> Except that code path is already too bloated and should be reduced not
> added to and conditionals are expensive.
> 
> 
> ---
>  kernel/hw_breakpoint.c |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
> index d71a987..f57ebee 100644
> --- a/kernel/hw_breakpoint.c
> +++ b/kernel/hw_breakpoint.c
> @@ -600,9 +600,20 @@ static int __init init_hw_breakpoint(void)
>  }
>  core_initcall(init_hw_breakpoint);
>  
> +static int hw_breakpoint_enable(struct perf_event *event)
> +{
> +	struct hw_perf_event *hwc = &event->hw;
> +
> +	if (hwc->sample_period) {
> +		hwc->last_period = hwc->sample_period;
> +		perf_swevent_set_period(event);
> +	}
> +
> +	return arch_install_hw_breakpoint(event);
> +}
>  
>  struct pmu perf_ops_bp = {
> -	.enable		= arch_install_hw_breakpoint,
> +	.enable		= hw_breakpoint_enable,
>  	.disable	= arch_uninstall_hw_breakpoint,
>  	.read		= hw_breakpoint_pmu_read,
>  };
> 
> 


  reply	other threads:[~2010-08-27 12:16 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
2010-08-26 12:36   ` DDD
2010-08-26 12:58     ` Peter Zijlstra
2010-08-27 12:21       ` DDD [this message]
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=4C77ADC1.5030502@windriver.com \
    --to=dongdong.deng@windriver.com \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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