[PATCH 03/21] perf_events: Add a helper to search for an event in a context
From: Borislav Petkov
Date: Thu Jul 01 2010 - 11:54:10 EST
From: Borislav Petkov <borislav.petkov@xxxxxxx>
This is a straignt-forward helper to look for, e.g. already allocated
and enabled events (think persistent events here).
Signed-off-by: Borislav Petkov <borislav.petkov@xxxxxxx>
---
kernel/perf_event.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 40478af..168764b 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -307,6 +307,27 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx)
ctx->nr_stat++;
}
+/*
+ * Find an event in a context.
+ * Must be called with ctx->mutex and ctx->lock held.
+ */
+static struct perf_event *find_event_in_context(struct perf_event_attr *attr,
+ struct perf_event_context *ctx)
+{
+ struct perf_event *event;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
+ if (event->attr.config == attr->config) {
+ rcu_read_unlock();
+ return event;
+ }
+ }
+ rcu_read_unlock();
+
+ return NULL;
+}
+
static void perf_group_attach(struct perf_event *event)
{
struct perf_event *group_leader = event->group_leader;
--
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/