diff options
author | Mark Rutland <mark.rutland@arm.com> | 2011-08-11 07:31:20 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2011-08-31 05:49:59 -0400 |
commit | 5f12a761937373d2f9b557d7519e6f1cf738b8f0 (patch) | |
tree | fe175ccc406d84cbe9a1cb5c7bffd76cb8cac0ea /kernel | |
parent | a505addc366525cd8d9358298be0dc8655be5953 (diff) |
perf: provide PMU when initing events
Currently, an event's 'pmu' field is set after pmu::event_init() is
called. This means that pmu::event_init() must figure out which struct
pmu the event was initialised from. This makes it difficult to
consolidate common event initialisation code for similar PMUs, and
very difficult to implement drivers for PMUs which can have multiple
instances (e.g. a USB controller PMU, a GPU PMU, etc).
This patch sets the 'pmu' field before initialising the event, allowing
event init code to identify the struct pmu instance easily. In the
event of failure to initialise an event, the event is destroyed via
kfree() without calling perf_event::destroy(), so this shouldn't
result in bad behaviour even if the destroy field was set before
failure to initialise was noted.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1313062280-19123-1-git-send-email-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index b8785e26ee1c..68c8017de969 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -5715,6 +5715,7 @@ struct pmu *perf_init_event(struct perf_event *event) | |||
5715 | pmu = idr_find(&pmu_idr, event->attr.type); | 5715 | pmu = idr_find(&pmu_idr, event->attr.type); |
5716 | rcu_read_unlock(); | 5716 | rcu_read_unlock(); |
5717 | if (pmu) { | 5717 | if (pmu) { |
5718 | event->pmu = pmu; | ||
5718 | ret = pmu->event_init(event); | 5719 | ret = pmu->event_init(event); |
5719 | if (ret) | 5720 | if (ret) |
5720 | pmu = ERR_PTR(ret); | 5721 | pmu = ERR_PTR(ret); |
@@ -5722,6 +5723,7 @@ struct pmu *perf_init_event(struct perf_event *event) | |||
5722 | } | 5723 | } |
5723 | 5724 | ||
5724 | list_for_each_entry_rcu(pmu, &pmus, entry) { | 5725 | list_for_each_entry_rcu(pmu, &pmus, entry) { |
5726 | event->pmu = pmu; | ||
5725 | ret = pmu->event_init(event); | 5727 | ret = pmu->event_init(event); |
5726 | if (!ret) | 5728 | if (!ret) |
5727 | goto unlock; | 5729 | goto unlock; |
@@ -5848,8 +5850,6 @@ done: | |||
5848 | return ERR_PTR(err); | 5850 | return ERR_PTR(err); |
5849 | } | 5851 | } |
5850 | 5852 | ||
5851 | event->pmu = pmu; | ||
5852 | |||
5853 | if (!event->parent) { | 5853 | if (!event->parent) { |
5854 | if (event->attach_state & PERF_ATTACH_TASK) | 5854 | if (event->attach_state & PERF_ATTACH_TASK) |
5855 | jump_label_inc(&perf_sched_events); | 5855 | jump_label_inc(&perf_sched_events); |