Skip to content

Commit

Permalink
perf: Allow for custom overflow handlers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Nov 21, 2009
1 parent ef6ae72 commit 453f19e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*/
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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:
*/
Expand Down

0 comments on commit 453f19e

Please sign in to comment.