aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2014-05-13 14:36:31 -0400
committerWill Deacon <will.deacon@arm.com>2014-10-30 08:17:00 -0400
commit116792508607002896b706fbad8310419fcc5742 (patch)
tree1b14145365bd4375a7ee927401d594917a8e127b /arch/arm/kernel
parenta4560846eba60830a444d9e336c8a18f92e099ee (diff)
arm: perf: kill get_hw_events()
Now that the arm pmu code is limited to CPU PMUs the get_hw_events() function is superfluous, as we'll always have a set of per-cpu pmu_hw_events structures. This patch removes the get_hw_events() function, replacing it with a percpu hw_events pointer. Uses of get_hw_events are updated to use this_cpu_ptr. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Stephen Boyd <sboyd@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.c6
-rw-r--r--arch/arm/kernel/perf_event_cpu.c7
-rw-r--r--arch/arm/kernel/perf_event_v6.c12
-rw-r--r--arch/arm/kernel/perf_event_v7.c14
-rw-r--r--arch/arm/kernel/perf_event_xscale.c20
5 files changed, 27 insertions, 32 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 864810713cfc..05ac5ee6e2bb 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -201,7 +201,7 @@ static void
201armpmu_del(struct perf_event *event, int flags) 201armpmu_del(struct perf_event *event, int flags)
202{ 202{
203 struct arm_pmu *armpmu = to_arm_pmu(event->pmu); 203 struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
204 struct pmu_hw_events *hw_events = armpmu->get_hw_events(); 204 struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
205 struct hw_perf_event *hwc = &event->hw; 205 struct hw_perf_event *hwc = &event->hw;
206 int idx = hwc->idx; 206 int idx = hwc->idx;
207 207
@@ -218,7 +218,7 @@ static int
218armpmu_add(struct perf_event *event, int flags) 218armpmu_add(struct perf_event *event, int flags)
219{ 219{
220 struct arm_pmu *armpmu = to_arm_pmu(event->pmu); 220 struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
221 struct pmu_hw_events *hw_events = armpmu->get_hw_events(); 221 struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
222 struct hw_perf_event *hwc = &event->hw; 222 struct hw_perf_event *hwc = &event->hw;
223 int idx; 223 int idx;
224 int err = 0; 224 int err = 0;
@@ -467,7 +467,7 @@ static int armpmu_event_init(struct perf_event *event)
467static void armpmu_enable(struct pmu *pmu) 467static void armpmu_enable(struct pmu *pmu)
468{ 468{
469 struct arm_pmu *armpmu = to_arm_pmu(pmu); 469 struct arm_pmu *armpmu = to_arm_pmu(pmu);
470 struct pmu_hw_events *hw_events = armpmu->get_hw_events(); 470 struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events);
471 int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); 471 int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events);
472 472
473 if (enabled) 473 if (enabled)
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
index 28d04642fa33..fd24ad84dba6 100644
--- a/arch/arm/kernel/perf_event_cpu.c
+++ b/arch/arm/kernel/perf_event_cpu.c
@@ -67,11 +67,6 @@ EXPORT_SYMBOL_GPL(perf_num_counters);
67#include "perf_event_v6.c" 67#include "perf_event_v6.c"
68#include "perf_event_v7.c" 68#include "perf_event_v7.c"
69 69
70static struct pmu_hw_events *cpu_pmu_get_cpu_events(void)
71{
72 return this_cpu_ptr(&cpu_hw_events);
73}
74
75static void cpu_pmu_enable_percpu_irq(void *data) 70static void cpu_pmu_enable_percpu_irq(void *data)
76{ 71{
77 int irq = *(int *)data; 72 int irq = *(int *)data;
@@ -174,7 +169,7 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
174 per_cpu(percpu_pmu, cpu) = cpu_pmu; 169 per_cpu(percpu_pmu, cpu) = cpu_pmu;
175 } 170 }
176 171
177 cpu_pmu->get_hw_events = cpu_pmu_get_cpu_events; 172 cpu_pmu->hw_events = &cpu_hw_events;
178 cpu_pmu->request_irq = cpu_pmu_request_irq; 173 cpu_pmu->request_irq = cpu_pmu_request_irq;
179 cpu_pmu->free_irq = cpu_pmu_free_irq; 174 cpu_pmu->free_irq = cpu_pmu_free_irq;
180 175
diff --git a/arch/arm/kernel/perf_event_v6.c b/arch/arm/kernel/perf_event_v6.c
index abfeb04f3213..f2ffd5c542ed 100644
--- a/arch/arm/kernel/perf_event_v6.c
+++ b/arch/arm/kernel/perf_event_v6.c
@@ -262,7 +262,7 @@ static void armv6pmu_enable_event(struct perf_event *event)
262 unsigned long val, mask, evt, flags; 262 unsigned long val, mask, evt, flags;
263 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 263 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
264 struct hw_perf_event *hwc = &event->hw; 264 struct hw_perf_event *hwc = &event->hw;
265 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 265 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
266 int idx = hwc->idx; 266 int idx = hwc->idx;
267 267
268 if (ARMV6_CYCLE_COUNTER == idx) { 268 if (ARMV6_CYCLE_COUNTER == idx) {
@@ -300,7 +300,7 @@ armv6pmu_handle_irq(int irq_num,
300 unsigned long pmcr = armv6_pmcr_read(); 300 unsigned long pmcr = armv6_pmcr_read();
301 struct perf_sample_data data; 301 struct perf_sample_data data;
302 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev; 302 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
303 struct pmu_hw_events *cpuc = cpu_pmu->get_hw_events(); 303 struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
304 struct pt_regs *regs; 304 struct pt_regs *regs;
305 int idx; 305 int idx;
306 306
@@ -356,7 +356,7 @@ armv6pmu_handle_irq(int irq_num,
356static void armv6pmu_start(struct arm_pmu *cpu_pmu) 356static void armv6pmu_start(struct arm_pmu *cpu_pmu)
357{ 357{
358 unsigned long flags, val; 358 unsigned long flags, val;
359 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 359 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
360 360
361 raw_spin_lock_irqsave(&events->pmu_lock, flags); 361 raw_spin_lock_irqsave(&events->pmu_lock, flags);
362 val = armv6_pmcr_read(); 362 val = armv6_pmcr_read();
@@ -368,7 +368,7 @@ static void armv6pmu_start(struct arm_pmu *cpu_pmu)
368static void armv6pmu_stop(struct arm_pmu *cpu_pmu) 368static void armv6pmu_stop(struct arm_pmu *cpu_pmu)
369{ 369{
370 unsigned long flags, val; 370 unsigned long flags, val;
371 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 371 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
372 372
373 raw_spin_lock_irqsave(&events->pmu_lock, flags); 373 raw_spin_lock_irqsave(&events->pmu_lock, flags);
374 val = armv6_pmcr_read(); 374 val = armv6_pmcr_read();
@@ -409,7 +409,7 @@ static void armv6pmu_disable_event(struct perf_event *event)
409 unsigned long val, mask, evt, flags; 409 unsigned long val, mask, evt, flags;
410 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 410 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
411 struct hw_perf_event *hwc = &event->hw; 411 struct hw_perf_event *hwc = &event->hw;
412 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 412 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
413 int idx = hwc->idx; 413 int idx = hwc->idx;
414 414
415 if (ARMV6_CYCLE_COUNTER == idx) { 415 if (ARMV6_CYCLE_COUNTER == idx) {
@@ -444,7 +444,7 @@ static void armv6mpcore_pmu_disable_event(struct perf_event *event)
444 unsigned long val, mask, flags, evt = 0; 444 unsigned long val, mask, flags, evt = 0;
445 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 445 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
446 struct hw_perf_event *hwc = &event->hw; 446 struct hw_perf_event *hwc = &event->hw;
447 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 447 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
448 int idx = hwc->idx; 448 int idx = hwc->idx;
449 449
450 if (ARMV6_CYCLE_COUNTER == idx) { 450 if (ARMV6_CYCLE_COUNTER == idx) {
diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
index d62b27ce55e9..8993770c47de 100644
--- a/arch/arm/kernel/perf_event_v7.c
+++ b/arch/arm/kernel/perf_event_v7.c
@@ -701,7 +701,7 @@ static void armv7pmu_enable_event(struct perf_event *event)
701 unsigned long flags; 701 unsigned long flags;
702 struct hw_perf_event *hwc = &event->hw; 702 struct hw_perf_event *hwc = &event->hw;
703 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 703 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
704 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 704 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
705 int idx = hwc->idx; 705 int idx = hwc->idx;
706 706
707 if (!armv7_pmnc_counter_valid(cpu_pmu, idx)) { 707 if (!armv7_pmnc_counter_valid(cpu_pmu, idx)) {
@@ -747,7 +747,7 @@ static void armv7pmu_disable_event(struct perf_event *event)
747 unsigned long flags; 747 unsigned long flags;
748 struct hw_perf_event *hwc = &event->hw; 748 struct hw_perf_event *hwc = &event->hw;
749 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 749 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
750 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 750 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
751 int idx = hwc->idx; 751 int idx = hwc->idx;
752 752
753 if (!armv7_pmnc_counter_valid(cpu_pmu, idx)) { 753 if (!armv7_pmnc_counter_valid(cpu_pmu, idx)) {
@@ -779,7 +779,7 @@ static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
779 u32 pmnc; 779 u32 pmnc;
780 struct perf_sample_data data; 780 struct perf_sample_data data;
781 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev; 781 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
782 struct pmu_hw_events *cpuc = cpu_pmu->get_hw_events(); 782 struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
783 struct pt_regs *regs; 783 struct pt_regs *regs;
784 int idx; 784 int idx;
785 785
@@ -839,7 +839,7 @@ static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
839static void armv7pmu_start(struct arm_pmu *cpu_pmu) 839static void armv7pmu_start(struct arm_pmu *cpu_pmu)
840{ 840{
841 unsigned long flags; 841 unsigned long flags;
842 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 842 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
843 843
844 raw_spin_lock_irqsave(&events->pmu_lock, flags); 844 raw_spin_lock_irqsave(&events->pmu_lock, flags);
845 /* Enable all counters */ 845 /* Enable all counters */
@@ -850,7 +850,7 @@ static void armv7pmu_start(struct arm_pmu *cpu_pmu)
850static void armv7pmu_stop(struct arm_pmu *cpu_pmu) 850static void armv7pmu_stop(struct arm_pmu *cpu_pmu)
851{ 851{
852 unsigned long flags; 852 unsigned long flags;
853 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 853 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
854 854
855 raw_spin_lock_irqsave(&events->pmu_lock, flags); 855 raw_spin_lock_irqsave(&events->pmu_lock, flags);
856 /* Disable all counters */ 856 /* Disable all counters */
@@ -1283,7 +1283,7 @@ static void krait_pmu_disable_event(struct perf_event *event)
1283 struct hw_perf_event *hwc = &event->hw; 1283 struct hw_perf_event *hwc = &event->hw;
1284 int idx = hwc->idx; 1284 int idx = hwc->idx;
1285 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 1285 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
1286 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 1286 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
1287 1287
1288 /* Disable counter and interrupt */ 1288 /* Disable counter and interrupt */
1289 raw_spin_lock_irqsave(&events->pmu_lock, flags); 1289 raw_spin_lock_irqsave(&events->pmu_lock, flags);
@@ -1309,7 +1309,7 @@ static void krait_pmu_enable_event(struct perf_event *event)
1309 struct hw_perf_event *hwc = &event->hw; 1309 struct hw_perf_event *hwc = &event->hw;
1310 int idx = hwc->idx; 1310 int idx = hwc->idx;
1311 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 1311 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
1312 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 1312 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
1313 1313
1314 /* 1314 /*
1315 * Enable counter and interrupt, and set the counter to count 1315 * Enable counter and interrupt, and set the counter to count
diff --git a/arch/arm/kernel/perf_event_xscale.c b/arch/arm/kernel/perf_event_xscale.c
index 08da0af550b7..8af9f1f82c68 100644
--- a/arch/arm/kernel/perf_event_xscale.c
+++ b/arch/arm/kernel/perf_event_xscale.c
@@ -138,7 +138,7 @@ xscale1pmu_handle_irq(int irq_num, void *dev)
138 unsigned long pmnc; 138 unsigned long pmnc;
139 struct perf_sample_data data; 139 struct perf_sample_data data;
140 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev; 140 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
141 struct pmu_hw_events *cpuc = cpu_pmu->get_hw_events(); 141 struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
142 struct pt_regs *regs; 142 struct pt_regs *regs;
143 int idx; 143 int idx;
144 144
@@ -198,7 +198,7 @@ static void xscale1pmu_enable_event(struct perf_event *event)
198 unsigned long val, mask, evt, flags; 198 unsigned long val, mask, evt, flags;
199 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 199 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
200 struct hw_perf_event *hwc = &event->hw; 200 struct hw_perf_event *hwc = &event->hw;
201 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 201 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
202 int idx = hwc->idx; 202 int idx = hwc->idx;
203 203
204 switch (idx) { 204 switch (idx) {
@@ -234,7 +234,7 @@ static void xscale1pmu_disable_event(struct perf_event *event)
234 unsigned long val, mask, evt, flags; 234 unsigned long val, mask, evt, flags;
235 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 235 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
236 struct hw_perf_event *hwc = &event->hw; 236 struct hw_perf_event *hwc = &event->hw;
237 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 237 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
238 int idx = hwc->idx; 238 int idx = hwc->idx;
239 239
240 switch (idx) { 240 switch (idx) {
@@ -287,7 +287,7 @@ xscale1pmu_get_event_idx(struct pmu_hw_events *cpuc,
287static void xscale1pmu_start(struct arm_pmu *cpu_pmu) 287static void xscale1pmu_start(struct arm_pmu *cpu_pmu)
288{ 288{
289 unsigned long flags, val; 289 unsigned long flags, val;
290 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 290 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
291 291
292 raw_spin_lock_irqsave(&events->pmu_lock, flags); 292 raw_spin_lock_irqsave(&events->pmu_lock, flags);
293 val = xscale1pmu_read_pmnc(); 293 val = xscale1pmu_read_pmnc();
@@ -299,7 +299,7 @@ static void xscale1pmu_start(struct arm_pmu *cpu_pmu)
299static void xscale1pmu_stop(struct arm_pmu *cpu_pmu) 299static void xscale1pmu_stop(struct arm_pmu *cpu_pmu)
300{ 300{
301 unsigned long flags, val; 301 unsigned long flags, val;
302 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 302 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
303 303
304 raw_spin_lock_irqsave(&events->pmu_lock, flags); 304 raw_spin_lock_irqsave(&events->pmu_lock, flags);
305 val = xscale1pmu_read_pmnc(); 305 val = xscale1pmu_read_pmnc();
@@ -485,7 +485,7 @@ xscale2pmu_handle_irq(int irq_num, void *dev)
485 unsigned long pmnc, of_flags; 485 unsigned long pmnc, of_flags;
486 struct perf_sample_data data; 486 struct perf_sample_data data;
487 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev; 487 struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
488 struct pmu_hw_events *cpuc = cpu_pmu->get_hw_events(); 488 struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
489 struct pt_regs *regs; 489 struct pt_regs *regs;
490 int idx; 490 int idx;
491 491
@@ -539,7 +539,7 @@ static void xscale2pmu_enable_event(struct perf_event *event)
539 unsigned long flags, ien, evtsel; 539 unsigned long flags, ien, evtsel;
540 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 540 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
541 struct hw_perf_event *hwc = &event->hw; 541 struct hw_perf_event *hwc = &event->hw;
542 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 542 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
543 int idx = hwc->idx; 543 int idx = hwc->idx;
544 544
545 ien = xscale2pmu_read_int_enable(); 545 ien = xscale2pmu_read_int_enable();
@@ -585,7 +585,7 @@ static void xscale2pmu_disable_event(struct perf_event *event)
585 unsigned long flags, ien, evtsel, of_flags; 585 unsigned long flags, ien, evtsel, of_flags;
586 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu); 586 struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
587 struct hw_perf_event *hwc = &event->hw; 587 struct hw_perf_event *hwc = &event->hw;
588 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 588 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
589 int idx = hwc->idx; 589 int idx = hwc->idx;
590 590
591 ien = xscale2pmu_read_int_enable(); 591 ien = xscale2pmu_read_int_enable();
@@ -651,7 +651,7 @@ out:
651static void xscale2pmu_start(struct arm_pmu *cpu_pmu) 651static void xscale2pmu_start(struct arm_pmu *cpu_pmu)
652{ 652{
653 unsigned long flags, val; 653 unsigned long flags, val;
654 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 654 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
655 655
656 raw_spin_lock_irqsave(&events->pmu_lock, flags); 656 raw_spin_lock_irqsave(&events->pmu_lock, flags);
657 val = xscale2pmu_read_pmnc() & ~XSCALE_PMU_CNT64; 657 val = xscale2pmu_read_pmnc() & ~XSCALE_PMU_CNT64;
@@ -663,7 +663,7 @@ static void xscale2pmu_start(struct arm_pmu *cpu_pmu)
663static void xscale2pmu_stop(struct arm_pmu *cpu_pmu) 663static void xscale2pmu_stop(struct arm_pmu *cpu_pmu)
664{ 664{
665 unsigned long flags, val; 665 unsigned long flags, val;
666 struct pmu_hw_events *events = cpu_pmu->get_hw_events(); 666 struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
667 667
668 raw_spin_lock_irqsave(&events->pmu_lock, flags); 668 raw_spin_lock_irqsave(&events->pmu_lock, flags);
669 val = xscale2pmu_read_pmnc(); 669 val = xscale2pmu_read_pmnc();