Skip to contentSkip to conversation

perf: Fix perf_event_for_each() to use sibling

PATCH In review Michael Ellerman 1 participant 2 messages Apr 11, 2012 – Apr 26, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix perf_event_for_each() to use sibling

In perf_event_for_each() we call a function on an event, and then iterate over the siblings of the event.

However we don't call the function on the siblings, we call it repeatedly on the original event - it seems "obvious" that we should be calling it with sibling as the argument.

It looks like this broke in commit 75f937f24bd9 ("Fix ctx->mutex vs counter->mutex inversion").

The only effect of the bug is that the PERF_IOC_FLAG_GROUP parameter to the ioctls doesn't work.

---

This one seems so simple that I keep thinking I've missed something, I'm sure someone will tell me if I have ;)

AFAICS tools/perf never exercises this, ie. it always individually enables counters - which might explain how it could be broken and no one has noticed.

---
 kernel/events/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/core.c +1 -1
index 1b5c081..b82121b 100644
@@ -3097,7 +3097,7 @@ static void perf_event_for_each(struct perf_event *event,
 	perf_event_for_each_child(event, func);
 	func(event);
 	list_for_each_entry(sibling, &event->sibling_list, group_entry)
-		perf_event_for_each_child(event, func);
+		perf_event_for_each_child(sibling, func);
 	mutex_unlock(&ctx->mutex);
 }
 
Signature · 1 line
1.7.5.4
#1 lore raw
Commit-ID:  724b6daa13e100067c30cfc4d1ad06629609dc4e
Gitweb:     http://git.kernel.org/tip/724b6daa13e100067c30cfc4d1ad06629609dc4e
Author:     Michael Ellerman <[email protected]>
AuthorDate: Wed, 11 Apr 2012 11:54:13 +1000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Apr 2012 13:51:31 +0200

perf: Fix perf_event_for_each() to use sibling

In perf_event_for_each() we call a function on an event, and then iterate over the siblings of the event.

However we don't call the function on the siblings, we call it repeatedly on the original event - it seems "obvious" that we should be calling it with sibling as the argument.

It looks like this broke in commit 75f937f24bd9 ("Fix ctx->mutex vs counter->mutex inversion").

The only effect of the bug is that the PERF_IOC_FLAG_GROUP parameter to the ioctls doesn't work.

---
 kernel/events/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/events/core.c +1 -1
index a6a9ec4..fd126f8 100644
@@ -3183,7 +3183,7 @@ static void perf_event_for_each(struct perf_event *event,
 	perf_event_for_each_child(event, func);
 	func(event);
 	list_for_each_entry(sibling, &event->sibling_list, group_entry)
-		perf_event_for_each_child(event, func);
+		perf_event_for_each_child(sibling, func);
 	mutex_unlock(&ctx->mutex);
 }