public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How about limiting refresh ioctl to sampling events ?
@ 2010-11-23 13:01 Franck Bui-Huu
  2010-11-23 13:07 ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Franck Bui-Huu @ 2010-11-23 13:01 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: lkml

Hello Peter,

I'm looking at the perf event stuff and wondering if
perf_event_refresh() should be limited to sampling events.

Does the following make sense ?

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 3b105e0..1a90a6c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1072,7 +1072,7 @@ static int perf_event_refresh(struct perf_event *event, int refresh)
 	/*
 	 * not supported on inherited events
 	 */
-	if (event->attr.inherit)
+	if (event->attr.inherit || !event->attr.sample_period)
 		return -EINVAL;
 
 	atomic_add(refresh, &event->event_limit);

Thanks
-- 
		Franck

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: How about limiting refresh ioctl to sampling events ?
  2010-11-23 13:01 How about limiting refresh ioctl to sampling events ? Franck Bui-Huu
@ 2010-11-23 13:07 ` Peter Zijlstra
  2010-11-23 13:19   ` Franck Bui-Huu
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2010-11-23 13:07 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: lkml

On Tue, 2010-11-23 at 14:01 +0100, Franck Bui-Huu wrote:
> Hello Peter,
> 
> I'm looking at the perf event stuff and wondering if
> perf_event_refresh() should be limited to sampling events.
> 
> Does the following make sense ?
> 
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 3b105e0..1a90a6c 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -1072,7 +1072,7 @@ static int perf_event_refresh(struct perf_event *event, int refresh)
>  	/*
>  	 * not supported on inherited events
>  	 */
> -	if (event->attr.inherit)
> +	if (event->attr.inherit || !event->attr.sample_period)
>  		return -EINVAL;
>  
>  	atomic_add(refresh, &event->event_limit);

Yes it does, please submit as a proper patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How about limiting refresh ioctl to sampling events ?
  2010-11-23 13:07 ` Peter Zijlstra
@ 2010-11-23 13:19   ` Franck Bui-Huu
  2010-11-23 13:46     ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Franck Bui-Huu @ 2010-11-23 13:19 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Franck Bui-Huu, lkml

Peter Zijlstra <a.p.zijlstra@chello.nl> writes:

> On Tue, 2010-11-23 at 14:01 +0100, Franck Bui-Huu wrote:
>> Hello Peter,
>> 
>> I'm looking at the perf event stuff and wondering if
>
>> perf_event_refresh() should be limited to sampling events.
>> 
>> Does the following make sense ?
>> 
>> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
>> index 3b105e0..1a90a6c 100644
>> --- a/kernel/perf_event.c
>> +++ b/kernel/perf_event.c
>> @@ -1072,7 +1072,7 @@ static int perf_event_refresh(struct perf_event *event, int refresh)
>>  	/*
>>  	 * not supported on inherited events
>>  	 */
>> -	if (event->attr.inherit)
>> +	if (event->attr.inherit || !event->attr.sample_period)
>>  		return -EINVAL;
>>  
>>  	atomic_add(refresh, &event->event_limit);
>
> Yes it does, please submit as a proper patch.

Ok.

I'm also wondering if you would accept a second patch which will
introduce:

static inline bool is_sampling_event(struct perf_event *event)
{
        return event->attr.sample_period != 0;
}

That would make the code slighlty easier to read IMHO.

-- 
		Franck

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How about limiting refresh ioctl to sampling events ?
  2010-11-23 13:19   ` Franck Bui-Huu
@ 2010-11-23 13:46     ` Peter Zijlstra
  2010-11-24 10:19       ` Francis Moreau
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2010-11-23 13:46 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: lkml, Francis Moreau

On Tue, 2010-11-23 at 14:19 +0100, Franck Bui-Huu wrote:
> Peter Zijlstra <a.p.zijlstra@chello.nl> writes:
> 
> > On Tue, 2010-11-23 at 14:01 +0100, Franck Bui-Huu wrote:
> >> Hello Peter,
> >> 
> >> I'm looking at the perf event stuff and wondering if
> >
> >> perf_event_refresh() should be limited to sampling events.
> >> 
> >> Does the following make sense ?
> >> 
> >> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> >> index 3b105e0..1a90a6c 100644
> >> --- a/kernel/perf_event.c
> >> +++ b/kernel/perf_event.c
> >> @@ -1072,7 +1072,7 @@ static int perf_event_refresh(struct perf_event *event, int refresh)
> >>  	/*
> >>  	 * not supported on inherited events
> >>  	 */
> >> -	if (event->attr.inherit)
> >> +	if (event->attr.inherit || !event->attr.sample_period)
> >>  		return -EINVAL;
> >>  
> >>  	atomic_add(refresh, &event->event_limit);
> >
> > Yes it does, please submit as a proper patch.
> 
> Ok.
> 
> I'm also wondering if you would accept a second patch which will
> introduce:
> 
> static inline bool is_sampling_event(struct perf_event *event)
> {
>         return event->attr.sample_period != 0;
> }
> 
> That would make the code slighlty easier to read IMHO.
> 

Sure, Francis might want that too, he found another something like this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How about limiting refresh ioctl to sampling events ?
  2010-11-23 13:46     ` Peter Zijlstra
@ 2010-11-24 10:19       ` Francis Moreau
  0 siblings, 0 replies; 5+ messages in thread
From: Francis Moreau @ 2010-11-24 10:19 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Franck Bui-Huu, lkml

Peter Zijlstra <a.p.zijlstra@chello.nl> writes:

[...]

>> I'm also wondering if you would accept a second patch which will
>> introduce:
>> 
>> static inline bool is_sampling_event(struct perf_event *event)
>> {
>>         return event->attr.sample_period != 0;
>> }
>> 
>> That would make the code slighlty easier to read IMHO.
>> 
>
> Sure, Francis might want that too, he found another something like this.

Yes there's another issue when counting events are used: they call
perf_event_output() when 'period_left' gets 0 where as they should not.

-- 
Francis

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-24 10:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-23 13:01 How about limiting refresh ioctl to sampling events ? Franck Bui-Huu
2010-11-23 13:07 ` Peter Zijlstra
2010-11-23 13:19   ` Franck Bui-Huu
2010-11-23 13:46     ` Peter Zijlstra
2010-11-24 10:19       ` Francis Moreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox