perf: Add context field to perf_event

The perf_event overflow handler does not receive any caller-derived
argument, so many callers need to resort to looking up the perf_event
in their local data structure.  This is ugly and doesn't scale if a
single callback services many perf_events.

Fix by adding a context parameter to perf_event_create_kernel_counter()
(and derived hardware breakpoints APIs) and storing it in the perf_event.
The field can be accessed from the callback as event->overflow_handler_context.
All callers are updated.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1309362157-6596-2-git-send-email-avi@redhat.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Avi Kivity
2011-06-29 18:42:35 +03:00
committed by Ingo Molnar
parent 89d6c0b5bd
commit 4dc0da8696
12 changed files with 44 additions and 20 deletions

View File

@@ -839,6 +839,7 @@ struct perf_event {
u64 id;
perf_overflow_handler_t overflow_handler;
void *overflow_handler_context;
#ifdef CONFIG_EVENT_TRACING
struct ftrace_event_call *tp_event;
@@ -960,7 +961,8 @@ extern struct perf_event *
perf_event_create_kernel_counter(struct perf_event_attr *attr,
int cpu,
struct task_struct *task,
perf_overflow_handler_t callback);
perf_overflow_handler_t callback,
void *context);
extern u64 perf_event_read_value(struct perf_event *event,
u64 *enabled, u64 *running);