Skip to contentSkip to conversation

How about limiting refresh ioctl to sampling events ?

PATCH Franck Bui-Huu 3 participants 5 messages Nov 23, 2010 – Nov 24, 2010

lore
Share & tools
lore
#0 lore raw

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 ?

kernel/perf_event.c +1 -1
index 3b105e0..1a90a6c 100644
@@ -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

Signature · 1 line
		Franck
#1 lore raw
Quoted 12 lines · Franck Bui-Huu

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 ?

kernel/perf_event.c +0 -0
index 3b105e0..1a90a6c 100644

kernel/perf_event.c static int perf_event_refresh(struct perf_event *event, int refresh) · line 1078

Quoted 8 lines
kernel/perf_event.c +1 -1
@@ -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.

#2 lore raw
Quoted 21 lines · Peter Zijlstra
Quoted 20 lines · Franck Bui-Huu

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 ?

kernel/perf_event.c +1 -1
index 3b105e0..1a90a6c 100644
@@ -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;
 
Quoted 3 lines

kernel/perf_event.c static int perf_event_refresh(struct perf_event *event, int refresh) · line 1078

Quoted 1 line
kernel/perf_event.c +0 -0
 	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.

Signature · 1 line
		Franck
#3 lore raw
Quoted 32 lines · Franck Bui-Huu
Quoted 21 lines · Peter Zijlstra
Quoted 20 lines · Franck Bui-Huu

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 ?

kernel/perf_event.c +1 -1
index 3b105e0..1a90a6c 100644
@@ -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;
 
Quoted 3 lines

kernel/perf_event.c static int perf_event_refresh(struct perf_event *event, int refresh) · line 1078

Quoted 1 line
kernel/perf_event.c +0 -0
 	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:

Quoted 7 lines

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.

#4 lore raw

Peter Zijlstra <[email protected]> writes:

[...]

Quoted 8 lines
Quoted 8 lines

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;
}
Quoted 4 lines
Quoted 2 lines

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.

Signature · 1 line
Francis