[RFC PATCH 1/2] perf: Enable group siblings on exec ifattr::enable_on_exec set

From: Lin Ming
Date: Wed Nov 10 2010 - 01:13:29 EST


Currently, only group leader is enabled on exec.
This patch enables all group events on exec if attr::enable_on_exec is
set.

This is needed by next patch.

Signed-off-by: Lin Ming <ming.m.lin@xxxxxxxxx>
---
kernel/perf_event.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 517d827..b94c18d 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1700,11 +1700,29 @@ static int event_enable_on_exec(struct perf_event *event,
if (event->state >= PERF_EVENT_STATE_INACTIVE)
return 0;

- __perf_event_mark_enabled(event, ctx);
+ event->state = PERF_EVENT_STATE_INACTIVE;

return 1;
}

+static int group_enable_on_exec(struct perf_event *event,
+ struct perf_event_context *ctx)
+{
+ int enabled = 0;
+ struct perf_event *sub;
+
+ list_for_each_entry(sub, &event->sibling_list, group_entry)
+ if (event_enable_on_exec(sub, ctx))
+ enabled++;
+
+ if (event_enable_on_exec(event, ctx))
+ enabled++;
+
+ __perf_event_mark_enabled(event, ctx);
+
+ return enabled;
+}
+
/*
* Enable all of a task's events that have been marked enable-on-exec.
* This expects task == current.
@@ -1725,13 +1743,13 @@ static void perf_event_enable_on_exec(struct perf_event_context *ctx)
raw_spin_lock(&ctx->lock);

list_for_each_entry(event, &ctx->pinned_groups, group_entry) {
- ret = event_enable_on_exec(event, ctx);
+ ret = group_enable_on_exec(event, ctx);
if (ret)
enabled = 1;
}

list_for_each_entry(event, &ctx->flexible_groups, group_entry) {
- ret = event_enable_on_exec(event, ctx);
+ ret = group_enable_on_exec(event, ctx);
if (ret)
enabled = 1;
}
--
1.7.1



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/