[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1277999763-20357-4-git-send-email-bp@amd64.org>
Date: Thu, 1 Jul 2010 17:55:45 +0200
From: Borislav Petkov <bp@...64.org>
To: <linux-kernel@...r.kernel.org>
Subject: [PATCH 03/21] perf_events: Add a helper to search for an event in a context
From: Borislav Petkov <borislav.petkov@....com>
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@....com>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists