diff options
author | Mark Rutland <mark.rutland@arm.com> | 2011-04-27 05:31:51 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2011-08-31 05:50:00 -0400 |
commit | 48957155f8791964d8567479e6986f88343aba38 (patch) | |
tree | 676a538a8d99cd2864525a4b62789ef203e6075c /arch/arm/kernel | |
parent | 5f12a761937373d2f9b557d7519e6f1cf738b8f0 (diff) |
ARM: perf: only register a CPU PMU when present
Currently, an "empty" struct pmu is registered as the CPU PMU,
regardless of whether there is a physical PMU. This burdens the
accessor functions with checks to see whether a PMU is actually
present.
This patch changes initialisation to register a PMU only if there is a
supported PMU present, and removes the checks that this change makes
redundant.
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')
-rw-r--r-- | arch/arm/kernel/perf_event.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 5d60c9c25964..753648cf9af6 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c | |||
@@ -250,9 +250,6 @@ armpmu_stop(struct perf_event *event, int flags) | |||
250 | { | 250 | { |
251 | struct hw_perf_event *hwc = &event->hw; | 251 | struct hw_perf_event *hwc = &event->hw; |
252 | 252 | ||
253 | if (!armpmu) | ||
254 | return; | ||
255 | |||
256 | /* | 253 | /* |
257 | * ARM pmu always has to update the counter, so ignore | 254 | * ARM pmu always has to update the counter, so ignore |
258 | * PERF_EF_UPDATE, see comments in armpmu_start(). | 255 | * PERF_EF_UPDATE, see comments in armpmu_start(). |
@@ -270,9 +267,6 @@ armpmu_start(struct perf_event *event, int flags) | |||
270 | { | 267 | { |
271 | struct hw_perf_event *hwc = &event->hw; | 268 | struct hw_perf_event *hwc = &event->hw; |
272 | 269 | ||
273 | if (!armpmu) | ||
274 | return; | ||
275 | |||
276 | /* | 270 | /* |
277 | * ARM pmu always has to reprogram the period, so ignore | 271 | * ARM pmu always has to reprogram the period, so ignore |
278 | * PERF_EF_RELOAD, see the comment below. | 272 | * PERF_EF_RELOAD, see the comment below. |
@@ -567,9 +561,6 @@ static int armpmu_event_init(struct perf_event *event) | |||
567 | return -ENOENT; | 561 | return -ENOENT; |
568 | } | 562 | } |
569 | 563 | ||
570 | if (!armpmu) | ||
571 | return -ENODEV; | ||
572 | |||
573 | event->destroy = hw_perf_event_destroy; | 564 | event->destroy = hw_perf_event_destroy; |
574 | 565 | ||
575 | if (!atomic_inc_not_zero(&active_events)) { | 566 | if (!atomic_inc_not_zero(&active_events)) { |
@@ -599,9 +590,6 @@ static void armpmu_enable(struct pmu *pmu) | |||
599 | int idx, enabled = 0; | 590 | int idx, enabled = 0; |
600 | struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); | 591 | struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); |
601 | 592 | ||
602 | if (!armpmu) | ||
603 | return; | ||
604 | |||
605 | for (idx = 0; idx < armpmu->num_events; ++idx) { | 593 | for (idx = 0; idx < armpmu->num_events; ++idx) { |
606 | struct perf_event *event = cpuc->events[idx]; | 594 | struct perf_event *event = cpuc->events[idx]; |
607 | 595 | ||
@@ -618,8 +606,7 @@ static void armpmu_enable(struct pmu *pmu) | |||
618 | 606 | ||
619 | static void armpmu_disable(struct pmu *pmu) | 607 | static void armpmu_disable(struct pmu *pmu) |
620 | { | 608 | { |
621 | if (armpmu) | 609 | armpmu->stop(); |
622 | armpmu->stop(); | ||
623 | } | 610 | } |
624 | 611 | ||
625 | static struct pmu pmu = { | 612 | static struct pmu pmu = { |
@@ -738,12 +725,11 @@ init_hw_perf_events(void) | |||
738 | if (armpmu) { | 725 | if (armpmu) { |
739 | pr_info("enabled with %s PMU driver, %d counters available\n", | 726 | pr_info("enabled with %s PMU driver, %d counters available\n", |
740 | armpmu->name, armpmu->num_events); | 727 | armpmu->name, armpmu->num_events); |
728 | perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); | ||
741 | } else { | 729 | } else { |
742 | pr_info("no hardware support available\n"); | 730 | pr_info("no hardware support available\n"); |
743 | } | 731 | } |
744 | 732 | ||
745 | perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); | ||
746 | |||
747 | return 0; | 733 | return 0; |
748 | } | 734 | } |
749 | early_initcall(init_hw_perf_events); | 735 | early_initcall(init_hw_perf_events); |