diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-11-20 16:19:43 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-21 08:11:35 -0500 |
commit | 453f19eea7dbad837425e9b07d84568d14898794 (patch) | |
tree | 3b1d757a72512b5ab566649b9eda59e032734993 | |
parent | ef6ae724253429ac70d81e65d052f6a346d330bd (diff) |
perf: Allow for custom overflow handlers
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>
-rw-r--r-- | include/linux/perf_event.h | 6 | ||||
-rw-r--r-- | kernel/perf_event.c | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b5cdac0de370..a430ac3074af 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -567,6 +567,8 @@ struct perf_pending_entry { | |||
567 | 567 | ||
568 | typedef void (*perf_callback_t)(struct perf_event *, void *); | 568 | typedef void (*perf_callback_t)(struct perf_event *, void *); |
569 | 569 | ||
570 | struct perf_sample_data; | ||
571 | |||
570 | /** | 572 | /** |
571 | * struct perf_event - performance event kernel representation: | 573 | * struct perf_event - performance event kernel representation: |
572 | */ | 574 | */ |
@@ -658,6 +660,10 @@ struct perf_event { | |||
658 | struct pid_namespace *ns; | 660 | struct pid_namespace *ns; |
659 | u64 id; | 661 | u64 id; |
660 | 662 | ||
663 | void (*overflow_handler)(struct perf_event *event, | ||
664 | int nmi, struct perf_sample_data *data, | ||
665 | struct pt_regs *regs); | ||
666 | |||
661 | #ifdef CONFIG_EVENT_PROFILE | 667 | #ifdef CONFIG_EVENT_PROFILE |
662 | struct event_filter *filter; | 668 | struct event_filter *filter; |
663 | #endif | 669 | #endif |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 3852e2656bb0..1dfb6cc4fdea 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -3710,7 +3710,11 @@ static int __perf_event_overflow(struct perf_event *event, int nmi, | |||
3710 | perf_event_disable(event); | 3710 | perf_event_disable(event); |
3711 | } | 3711 | } |
3712 | 3712 | ||
3713 | perf_event_output(event, nmi, data, regs); | 3713 | if (event->overflow_handler) |
3714 | event->overflow_handler(event, nmi, data, regs); | ||
3715 | else | ||
3716 | perf_event_output(event, nmi, data, regs); | ||
3717 | |||
3714 | return ret; | 3718 | return ret; |
3715 | } | 3719 | } |
3716 | 3720 | ||
@@ -4836,6 +4840,8 @@ inherit_event(struct perf_event *parent_event, | |||
4836 | if (parent_event->attr.freq) | 4840 | if (parent_event->attr.freq) |
4837 | child_event->hw.sample_period = parent_event->hw.sample_period; | 4841 | child_event->hw.sample_period = parent_event->hw.sample_period; |
4838 | 4842 | ||
4843 | child_event->overflow_handler = parent_event->overflow_handler; | ||
4844 | |||
4839 | /* | 4845 | /* |
4840 | * Link it up in the child's context: | 4846 | * Link it up in the child's context: |
4841 | */ | 4847 | */ |