perf: provide PMU when initing events
authorMark Rutland <mark.rutland@arm.com>
Thu, 11 Aug 2011 11:31:20 +0000 (12:31 +0100)
committerWill Deacon <will.deacon@arm.com>
Wed, 31 Aug 2011 09:49:59 +0000 (10:49 +0100)
commit5f12a761937373d2f9b557d7519e6f1cf738b8f0
treefe175ccc406d84cbe9a1cb5c7bffd76cb8cac0ea
parenta505addc366525cd8d9358298be0dc8655be5953
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>
kernel/events/core.c