From: Borislav Petkov on 1 Jul 2010 12:00 From: Borislav Petkov <borislav.petkov(a)amd.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(a)amd.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(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Pages: 1 Prev: [RFC PATCH 00/21] RAS daemon prototype, v1 Next: [PATCH] digital compass hmc5843 |