aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/perf_event.c
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2011-05-04 04:23:51 -0400
committerWill Deacon <will.deacon@arm.com>2011-08-31 05:50:05 -0400
commit92f701e1f429e007f9619469d548022061c41ecc (patch)
treece70ecb1b103c52f7ddee02a935f940a59c7d76e /arch/arm/kernel/perf_event.c
parenta9356a04fab912289b886824cb4b1d461987a910 (diff)
ARM: perf: indirect access to cpu_hw_events
Currently, cpu_hw_events is a global per-CPU variable. To enable support for multiple PMUs, there needs to be a mapping from an instance of arm_pmu to its cpu_hw_events. Additionally, as system PMUs are not CPU-affine, they should not have this stored per-CPU. This patch moves access to the hardware events data behind an accessor function (arm_pmu::get_hw_events). This allows each instance to have its own hardware event data, which can be stored per-CPU or globally as required. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Jamie Iles <jamie@jamieiles.com> Reviewed-by: Ashwin Chaugule <ashwinc@codeaurora.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm/kernel/perf_event.c')
-rw-r--r--arch/arm/kernel/perf_event.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 1d648d136413..9d6ac99de30b 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -84,6 +84,7 @@ struct arm_pmu {
84 struct mutex reserve_mutex; 84 struct mutex reserve_mutex;
85 u64 max_period; 85 u64 max_period;
86 struct platform_device *plat_device; 86 struct platform_device *plat_device;
87 struct cpu_hw_events *(*get_hw_events)(void);
87}; 88};
88 89
89/* Set at runtime when we know what CPU type we are. */ 90/* Set at runtime when we know what CPU type we are. */
@@ -284,7 +285,7 @@ armpmu_start(struct perf_event *event, int flags)
284static void 285static void
285armpmu_del(struct perf_event *event, int flags) 286armpmu_del(struct perf_event *event, int flags)
286{ 287{
287 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 288 struct cpu_hw_events *cpuc = armpmu->get_hw_events();
288 struct hw_perf_event *hwc = &event->hw; 289 struct hw_perf_event *hwc = &event->hw;
289 int idx = hwc->idx; 290 int idx = hwc->idx;
290 291
@@ -300,7 +301,7 @@ armpmu_del(struct perf_event *event, int flags)
300static int 301static int
301armpmu_add(struct perf_event *event, int flags) 302armpmu_add(struct perf_event *event, int flags)
302{ 303{
303 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 304 struct cpu_hw_events *cpuc = armpmu->get_hw_events();
304 struct hw_perf_event *hwc = &event->hw; 305 struct hw_perf_event *hwc = &event->hw;
305 int idx; 306 int idx;
306 int err = 0; 307 int err = 0;
@@ -585,7 +586,7 @@ static void armpmu_enable(struct pmu *pmu)
585{ 586{
586 /* Enable all of the perf events on hardware. */ 587 /* Enable all of the perf events on hardware. */
587 int idx, enabled = 0; 588 int idx, enabled = 0;
588 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 589 struct cpu_hw_events *cpuc = armpmu->get_hw_events();
589 590
590 for (idx = 0; idx < armpmu->num_events; ++idx) { 591 for (idx = 0; idx < armpmu->num_events; ++idx) {
591 struct perf_event *event = cpuc->events[idx]; 592 struct perf_event *event = cpuc->events[idx];
@@ -678,6 +679,16 @@ static int __init register_pmu_driver(void)
678} 679}
679device_initcall(register_pmu_driver); 680device_initcall(register_pmu_driver);
680 681
682static struct cpu_hw_events *armpmu_get_cpu_events(void)
683{
684 return &__get_cpu_var(cpu_hw_events);
685}
686
687static void __init cpu_pmu_init(struct arm_pmu *armpmu)
688{
689 armpmu->get_hw_events = armpmu_get_cpu_events;
690}
691
681/* 692/*
682 * CPU PMU identification and registration. 693 * CPU PMU identification and registration.
683 */ 694 */
@@ -728,6 +739,7 @@ init_hw_perf_events(void)
728 if (armpmu) { 739 if (armpmu) {
729 pr_info("enabled with %s PMU driver, %d counters available\n", 740 pr_info("enabled with %s PMU driver, %d counters available\n",
730 armpmu->name, armpmu->num_events); 741 armpmu->name, armpmu->num_events);
742 cpu_pmu_init(armpmu);
731 armpmu_init(armpmu); 743 armpmu_init(armpmu);
732 perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); 744 perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
733 } else { 745 } else {