Skip to content

Commit 4295b89

Browse files
wildea01Russell King
authored andcommitted
ARM: 7448/1: perf: remove arm_perf_pmu_ids global enumeration
In order to provide PMU name strings compatible with the OProfile user ABI, an enumeration of all PMUs is currently used by perf to identify each PMU uniquely. Unfortunately, this does not scale well in the presence of multiple PMUs and creates a single, global namespace across all PMUs in the system. This patch removes the enumeration and instead uses the name string for the PMU to map onto the OProfile variant. perf_pmu_name is implemented for CPU PMUs, which is all that OProfile cares about anyway. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 881cccc commit 4295b89

7 files changed

Lines changed: 36 additions & 53 deletions

File tree

‎arch/arm/include/asm/perf_event.h‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@
1212
#ifndef __ARM_PERF_EVENT_H__
1313
#define __ARM_PERF_EVENT_H__
1414

15-
/* ARM perf PMU IDs for use by internal perf clients. */
16-
enum arm_perf_pmu_ids {
17-
ARM_PERF_PMU_ID_XSCALE1 = 0,
18-
ARM_PERF_PMU_ID_XSCALE2,
19-
ARM_PERF_PMU_ID_V6,
20-
ARM_PERF_PMU_ID_V6MP,
21-
ARM_PERF_PMU_ID_CA8,
22-
ARM_PERF_PMU_ID_CA9,
23-
ARM_PERF_PMU_ID_CA5,
24-
ARM_PERF_PMU_ID_CA15,
25-
ARM_PERF_PMU_ID_CA7,
26-
ARM_NUM_PMU_IDS,
27-
};
28-
29-
extern enum arm_perf_pmu_ids
30-
armpmu_get_pmu_id(void);
15+
/* Nothing to see here... */
3116

3217
#endif /* __ARM_PERF_EVENT_H__ */

‎arch/arm/include/asm/pmu.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ struct pmu_hw_events {
103103

104104
struct arm_pmu {
105105
struct pmu pmu;
106-
enum arm_perf_pmu_ids id;
107106
enum arm_pmu_type type;
108107
cpumask_t active_irqs;
109-
const char *name;
108+
char *name;
110109
irqreturn_t (*handle_irq)(int irq_num, void *dev);
111110
void (*enable)(struct hw_perf_event *evt, int idx);
112111
void (*disable)(struct hw_perf_event *evt, int idx);

‎arch/arm/kernel/perf_event.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,14 @@ static DEFINE_PER_CPU(struct pmu_hw_events, cpu_hw_events);
4747
/* Set at runtime when we know what CPU type we are. */
4848
static struct arm_pmu *cpu_pmu;
4949

50-
enum arm_perf_pmu_ids
51-
armpmu_get_pmu_id(void)
50+
const char *perf_pmu_name(void)
5251
{
53-
int id = -ENODEV;
54-
55-
if (cpu_pmu != NULL)
56-
id = cpu_pmu->id;
52+
if (!cpu_pmu)
53+
return NULL;
5754

58-
return id;
55+
return cpu_pmu->pmu.name;
5956
}
60-
EXPORT_SYMBOL_GPL(armpmu_get_pmu_id);
57+
EXPORT_SYMBOL_GPL(perf_pmu_name);
6158

6259
int perf_num_counters(void)
6360
{
@@ -760,7 +757,7 @@ init_hw_perf_events(void)
760757
cpu_pmu->name, cpu_pmu->num_events);
761758
cpu_pmu_init(cpu_pmu);
762759
register_cpu_notifier(&pmu_cpu_notifier);
763-
armpmu_register(cpu_pmu, "cpu", PERF_TYPE_RAW);
760+
armpmu_register(cpu_pmu, cpu_pmu->name, PERF_TYPE_RAW);
764761
} else {
765762
pr_info("no hardware support available\n");
766763
}

‎arch/arm/kernel/perf_event_v6.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@ static int armv6_map_event(struct perf_event *event)
650650
}
651651

652652
static struct arm_pmu armv6pmu = {
653-
.id = ARM_PERF_PMU_ID_V6,
654653
.name = "v6",
655654
.handle_irq = armv6pmu_handle_irq,
656655
.enable = armv6pmu_enable_event,
@@ -685,7 +684,6 @@ static int armv6mpcore_map_event(struct perf_event *event)
685684
}
686685

687686
static struct arm_pmu armv6mpcore_pmu = {
688-
.id = ARM_PERF_PMU_ID_V6MP,
689687
.name = "v6mpcore",
690688
.handle_irq = armv6pmu_handle_irq,
691689
.enable = armv6pmu_enable_event,

‎arch/arm/kernel/perf_event_v7.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,6 @@ static u32 __init armv7_read_num_pmnc_events(void)
12581258

12591259
static struct arm_pmu *__init armv7_a8_pmu_init(void)
12601260
{
1261-
armv7pmu.id = ARM_PERF_PMU_ID_CA8;
12621261
armv7pmu.name = "ARMv7 Cortex-A8";
12631262
armv7pmu.map_event = armv7_a8_map_event;
12641263
armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1267,7 +1266,6 @@ static struct arm_pmu *__init armv7_a8_pmu_init(void)
12671266

12681267
static struct arm_pmu *__init armv7_a9_pmu_init(void)
12691268
{
1270-
armv7pmu.id = ARM_PERF_PMU_ID_CA9;
12711269
armv7pmu.name = "ARMv7 Cortex-A9";
12721270
armv7pmu.map_event = armv7_a9_map_event;
12731271
armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1276,7 +1274,6 @@ static struct arm_pmu *__init armv7_a9_pmu_init(void)
12761274

12771275
static struct arm_pmu *__init armv7_a5_pmu_init(void)
12781276
{
1279-
armv7pmu.id = ARM_PERF_PMU_ID_CA5;
12801277
armv7pmu.name = "ARMv7 Cortex-A5";
12811278
armv7pmu.map_event = armv7_a5_map_event;
12821279
armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1285,7 +1282,6 @@ static struct arm_pmu *__init armv7_a5_pmu_init(void)
12851282

12861283
static struct arm_pmu *__init armv7_a15_pmu_init(void)
12871284
{
1288-
armv7pmu.id = ARM_PERF_PMU_ID_CA15;
12891285
armv7pmu.name = "ARMv7 Cortex-A15";
12901286
armv7pmu.map_event = armv7_a15_map_event;
12911287
armv7pmu.num_events = armv7_read_num_pmnc_events();
@@ -1295,7 +1291,6 @@ static struct arm_pmu *__init armv7_a15_pmu_init(void)
12951291

12961292
static struct arm_pmu *__init armv7_a7_pmu_init(void)
12971293
{
1298-
armv7pmu.id = ARM_PERF_PMU_ID_CA7;
12991294
armv7pmu.name = "ARMv7 Cortex-A7";
13001295
armv7pmu.map_event = armv7_a7_map_event;
13011296
armv7pmu.num_events = armv7_read_num_pmnc_events();

‎arch/arm/kernel/perf_event_xscale.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ static int xscale_map_event(struct perf_event *event)
435435
}
436436

437437
static struct arm_pmu xscale1pmu = {
438-
.id = ARM_PERF_PMU_ID_XSCALE1,
439438
.name = "xscale1",
440439
.handle_irq = xscale1pmu_handle_irq,
441440
.enable = xscale1pmu_enable_event,
@@ -803,7 +802,6 @@ xscale2pmu_write_counter(int counter, u32 val)
803802
}
804803

805804
static struct arm_pmu xscale2pmu = {
806-
.id = ARM_PERF_PMU_ID_XSCALE2,
807805
.name = "xscale2",
808806
.handle_irq = xscale2pmu_handle_irq,
809807
.enable = xscale2pmu_enable_event,

‎arch/arm/oprofile/common.c‎

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,37 @@
2323
#include <asm/ptrace.h>
2424

2525
#ifdef CONFIG_HW_PERF_EVENTS
26+
27+
/*
28+
* OProfile has a curious naming scheme for the ARM PMUs, but they are
29+
* part of the user ABI so we need to map from the perf PMU name for
30+
* supported PMUs.
31+
*/
32+
static struct op_perf_name {
33+
char *perf_name;
34+
char *op_name;
35+
} op_perf_name_map[] = {
36+
{ "xscale1", "arm/xscale1" },
37+
{ "xscale1", "arm/xscale2" },
38+
{ "v6", "arm/armv6" },
39+
{ "v6mpcore", "arm/mpcore" },
40+
{ "ARMv7 Cortex-A8", "arm/armv7" },
41+
{ "ARMv7 Cortex-A9", "arm/armv7-ca9" },
42+
};
43+
2644
char *op_name_from_perf_id(void)
2745
{
28-
enum arm_perf_pmu_ids id = armpmu_get_pmu_id();
29-
30-
switch (id) {
31-
case ARM_PERF_PMU_ID_XSCALE1:
32-
return "arm/xscale1";
33-
case ARM_PERF_PMU_ID_XSCALE2:
34-
return "arm/xscale2";
35-
case ARM_PERF_PMU_ID_V6:
36-
return "arm/armv6";
37-
case ARM_PERF_PMU_ID_V6MP:
38-
return "arm/mpcore";
39-
case ARM_PERF_PMU_ID_CA8:
40-
return "arm/armv7";
41-
case ARM_PERF_PMU_ID_CA9:
42-
return "arm/armv7-ca9";
43-
default:
44-
return NULL;
46+
int i;
47+
struct op_perf_name names;
48+
const char *perf_name = perf_pmu_name();
49+
50+
for (i = 0; i < ARRAY_SIZE(op_perf_name_map); ++i) {
51+
names = op_perf_name_map[i];
52+
if (!strcmp(names.perf_name, perf_name))
53+
return names.op_name;
4554
}
55+
56+
return NULL;
4657
}
4758
#endif
4859

0 commit comments

Comments
 (0)