perf: Allow for custom overflow handlers
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Fri, 20 Nov 2009 21:19:43 +0000 (22:19 +0100)
committerIngo Molnar <mingo@elte.hu>
Sat, 21 Nov 2009 13:11:35 +0000 (14:11 +0100)
in-kernel perf users might wish to have custom actions on the
sample interrupt.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091120212508.222339539@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/perf_event.h
kernel/perf_event.c

index b5cdac0de370ce538241eba6aa50e1547ac43f7a..a430ac3074afb7091866d0b695ad2f570eae7a31 100644 (file)
@@ -567,6 +567,8 @@ struct perf_pending_entry {
 
 typedef void (*perf_callback_t)(struct perf_event *, void *);
 
+struct perf_sample_data;
+
 /**
  * struct perf_event - performance event kernel representation:
  */
@@ -658,6 +660,10 @@ struct perf_event {
        struct pid_namespace            *ns;
        u64                             id;
 
+       void (*overflow_handler)(struct perf_event *event,
+                       int nmi, struct perf_sample_data *data,
+                       struct pt_regs *regs);
+
 #ifdef CONFIG_EVENT_PROFILE
        struct event_filter             *filter;
 #endif
index 3852e2656bb0d36db15c879bac5a8af8822e0592..1dfb6cc4fdeaec9292d39d2da2adec991ad091b3 100644 (file)
@@ -3710,7 +3710,11 @@ static int __perf_event_overflow(struct perf_event *event, int nmi,
                        perf_event_disable(event);
        }
 
-       perf_event_output(event, nmi, data, regs);
+       if (event->overflow_handler)
+               event->overflow_handler(event, nmi, data, regs);
+       else
+               perf_event_output(event, nmi, data, regs);
+
        return ret;
 }
 
@@ -4836,6 +4840,8 @@ inherit_event(struct perf_event *parent_event,
        if (parent_event->attr.freq)
                child_event->hw.sample_period = parent_event->hw.sample_period;
 
+       child_event->overflow_handler = parent_event->overflow_handler;
+
        /*
         * Link it up in the child's context:
         */