Commit 1ba3752a authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf pmu-events: Hide the pmu_events

Hide that the pmu_event structs are an array with a new wrapper struct.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Will Deacon <will@kernel.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20220812230949.683239-12-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 660842e4
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "../../../util/cpumap.h" #include "../../../util/cpumap.h"
#include "../../../util/pmu.h" #include "../../../util/pmu.h"
const struct pmu_event *pmu_events_table__find(void) const struct pmu_events_table *pmu_events_table__find(void)
{ {
struct perf_pmu *pmu = NULL; struct perf_pmu *pmu = NULL;
......
...@@ -176,6 +176,10 @@ static const struct pmu_event pme_test_soc_cpu[] = { ...@@ -176,6 +176,10 @@ static const struct pmu_event pme_test_soc_cpu[] = {
}, },
}; };
/* Struct used to make the PMU event table implementation opaque to callers. */
struct pmu_events_table {
const struct pmu_event *entries;
};
/* /*
* Map a CPU to its table of PMU events. The CPU is identified by the * Map a CPU to its table of PMU events. The CPU is identified by the
...@@ -188,7 +192,7 @@ static const struct pmu_event pme_test_soc_cpu[] = { ...@@ -188,7 +192,7 @@ static const struct pmu_event pme_test_soc_cpu[] = {
struct pmu_events_map { struct pmu_events_map {
const char *arch; const char *arch;
const char *cpuid; const char *cpuid;
const struct pmu_event *table; const struct pmu_events_table table;
}; };
/* /*
...@@ -199,12 +203,12 @@ static const struct pmu_events_map pmu_events_map[] = { ...@@ -199,12 +203,12 @@ static const struct pmu_events_map pmu_events_map[] = {
{ {
.arch = "testarch", .arch = "testarch",
.cpuid = "testcpu", .cpuid = "testcpu",
.table = pme_test_soc_cpu, .table = { pme_test_soc_cpu },
}, },
{ {
.arch = 0, .arch = 0,
.cpuid = 0, .cpuid = 0,
.table = 0, .table = { 0 },
}, },
}; };
...@@ -234,23 +238,23 @@ static const struct pmu_event pme_test_soc_sys[] = { ...@@ -234,23 +238,23 @@ static const struct pmu_event pme_test_soc_sys[] = {
struct pmu_sys_events { struct pmu_sys_events {
const char *name; const char *name;
const struct pmu_event *table; const struct pmu_events_table table;
}; };
static const struct pmu_sys_events pmu_sys_event_tables[] = { static const struct pmu_sys_events pmu_sys_event_tables[] = {
{ {
.table = pme_test_soc_sys, .table = { pme_test_soc_sys },
.name = "pme_test_soc_sys", .name = "pme_test_soc_sys",
}, },
{ {
.table = 0 .table = { 0 }
}, },
}; };
int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_iter_fn fn, int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
void *data) void *data)
{ {
for (const struct pmu_event *pe = &table[0]; for (const struct pmu_event *pe = &table->entries[0];
pe->name || pe->metric_group || pe->metric_name; pe->name || pe->metric_group || pe->metric_name;
pe++) { pe++) {
int ret = fn(pe, table, data); int ret = fn(pe, table, data);
...@@ -261,9 +265,9 @@ int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_ite ...@@ -261,9 +265,9 @@ int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_ite
return 0; return 0;
} }
const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu)
{ {
const struct pmu_event *table = NULL; const struct pmu_events_table *table = NULL;
char *cpuid = perf_pmu__getcpuid(pmu); char *cpuid = perf_pmu__getcpuid(pmu);
int i; int i;
...@@ -277,11 +281,11 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) ...@@ -277,11 +281,11 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu)
for (;;) { for (;;) {
const struct pmu_events_map *map = &pmu_events_map[i++]; const struct pmu_events_map *map = &pmu_events_map[i++];
if (!map->table) if (!map->cpuid)
break; break;
if (!strcmp_cpuid_str(map->cpuid, cpuid)) { if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
table = map->table; table = &map->table;
break; break;
} }
} }
...@@ -289,13 +293,13 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) ...@@ -289,13 +293,13 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu)
return table; return table;
} }
const struct pmu_event *find_core_events_table(const char *arch, const char *cpuid) const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
{ {
for (const struct pmu_events_map *tables = &pmu_events_map[0]; for (const struct pmu_events_map *tables = &pmu_events_map[0];
tables->table; tables->arch;
tables++) { tables++) {
if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid)) if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
return tables->table; return &tables->table;
} }
return NULL; return NULL;
} }
...@@ -303,9 +307,9 @@ const struct pmu_event *find_core_events_table(const char *arch, const char *cpu ...@@ -303,9 +307,9 @@ const struct pmu_event *find_core_events_table(const char *arch, const char *cpu
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data)
{ {
for (const struct pmu_events_map *tables = &pmu_events_map[0]; for (const struct pmu_events_map *tables = &pmu_events_map[0];
tables->table; tables->arch;
tables++) { tables++) {
int ret = pmu_events_table_for_each_event(tables->table, fn, data); int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
...@@ -313,13 +317,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) ...@@ -313,13 +317,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data)
return 0; return 0;
} }
const struct pmu_event *find_sys_events_table(const char *name) const struct pmu_events_table *find_sys_events_table(const char *name)
{ {
for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0]; for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
tables->name; tables->name;
tables++) { tables++) {
if (!strcmp(tables->name, name)) if (!strcmp(tables->name, name))
return tables->table; return &tables->table;
} }
return NULL; return NULL;
} }
...@@ -329,7 +333,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data) ...@@ -329,7 +333,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data)
for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0]; for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
tables->name; tables->name;
tables++) { tables++) {
int ret = pmu_events_table_for_each_event(tables->table, fn, data); int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
......
...@@ -335,6 +335,11 @@ def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None: ...@@ -335,6 +335,11 @@ def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
def print_mapping_table(archs: Sequence[str]) -> None: def print_mapping_table(archs: Sequence[str]) -> None:
"""Read the mapfile and generate the struct from cpuid string to event table.""" """Read the mapfile and generate the struct from cpuid string to event table."""
_args.output_file.write(""" _args.output_file.write("""
/* Struct used to make the PMU event table implementation opaque to callers. */
struct pmu_events_table {
const struct pmu_event *entries;
};
/* /*
* Map a CPU to its table of PMU events. The CPU is identified by the * Map a CPU to its table of PMU events. The CPU is identified by the
* cpuid field, which is an arch-specific identifier for the CPU. * cpuid field, which is an arch-specific identifier for the CPU.
...@@ -346,7 +351,7 @@ def print_mapping_table(archs: Sequence[str]) -> None: ...@@ -346,7 +351,7 @@ def print_mapping_table(archs: Sequence[str]) -> None:
struct pmu_events_map { struct pmu_events_map {
const char *arch; const char *arch;
const char *cpuid; const char *cpuid;
const struct pmu_event *table; struct pmu_events_table table;
}; };
/* /*
...@@ -360,7 +365,7 @@ const struct pmu_events_map pmu_events_map[] = { ...@@ -360,7 +365,7 @@ const struct pmu_events_map pmu_events_map[] = {
_args.output_file.write("""{ _args.output_file.write("""{
\t.arch = "testarch", \t.arch = "testarch",
\t.cpuid = "testcpu", \t.cpuid = "testcpu",
\t.table = pme_test_soc_cpu, \t.table = { pme_test_soc_cpu },
}, },
""") """)
else: else:
...@@ -375,7 +380,7 @@ const struct pmu_events_map pmu_events_map[] = { ...@@ -375,7 +380,7 @@ const struct pmu_events_map pmu_events_map[] = {
_args.output_file.write(f"""{{ _args.output_file.write(f"""{{
\t.arch = "{arch}", \t.arch = "{arch}",
\t.cpuid = "{cpuid}", \t.cpuid = "{cpuid}",
\t.table = {tblname} \t.table = {{ {tblname} }}
}}, }},
""") """)
first = False first = False
...@@ -383,7 +388,7 @@ const struct pmu_events_map pmu_events_map[] = { ...@@ -383,7 +388,7 @@ const struct pmu_events_map pmu_events_map[] = {
_args.output_file.write("""{ _args.output_file.write("""{
\t.arch = 0, \t.arch = 0,
\t.cpuid = 0, \t.cpuid = 0,
\t.table = 0, \t.table = { 0 },
} }
}; };
""") """)
...@@ -394,26 +399,26 @@ def print_system_mapping_table() -> None: ...@@ -394,26 +399,26 @@ def print_system_mapping_table() -> None:
_args.output_file.write(""" _args.output_file.write("""
struct pmu_sys_events { struct pmu_sys_events {
\tconst char *name; \tconst char *name;
\tconst struct pmu_event *table; \tstruct pmu_events_table table;
}; };
static const struct pmu_sys_events pmu_sys_event_tables[] = { static const struct pmu_sys_events pmu_sys_event_tables[] = {
""") """)
for tblname in _sys_event_tables: for tblname in _sys_event_tables:
_args.output_file.write(f"""\t{{ _args.output_file.write(f"""\t{{
\t\t.table = {tblname}, \t\t.table = {{ {tblname} }},
\t\t.name = \"{tblname}\", \t\t.name = \"{tblname}\",
\t}}, \t}},
""") """)
_args.output_file.write("""\t{ _args.output_file.write("""\t{
\t\t.table = 0 \t\t.table = { 0 }
\t}, \t},
}; };
int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_iter_fn fn, int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
void *data) void *data)
{ {
for (const struct pmu_event *pe = &table[0]; for (const struct pmu_event *pe = &table->entries[0];
pe->name || pe->metric_group || pe->metric_name; pe->name || pe->metric_group || pe->metric_name;
pe++) { pe++) {
int ret = fn(pe, table, data); int ret = fn(pe, table, data);
...@@ -424,9 +429,9 @@ int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_ite ...@@ -424,9 +429,9 @@ int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_ite
return 0; return 0;
} }
const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu)
{ {
const struct pmu_event *table = NULL; const struct pmu_events_table *table = NULL;
char *cpuid = perf_pmu__getcpuid(pmu); char *cpuid = perf_pmu__getcpuid(pmu);
int i; int i;
...@@ -439,11 +444,11 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) ...@@ -439,11 +444,11 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu)
i = 0; i = 0;
for (;;) { for (;;) {
const struct pmu_events_map *map = &pmu_events_map[i++]; const struct pmu_events_map *map = &pmu_events_map[i++];
if (!map->table) if (!map->arch)
break; break;
if (!strcmp_cpuid_str(map->cpuid, cpuid)) { if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
table = map->table; table = &map->table;
break; break;
} }
} }
...@@ -451,13 +456,13 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) ...@@ -451,13 +456,13 @@ const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu)
return table; return table;
} }
const struct pmu_event *find_core_events_table(const char *arch, const char *cpuid) const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
{ {
for (const struct pmu_events_map *tables = &pmu_events_map[0]; for (const struct pmu_events_map *tables = &pmu_events_map[0];
tables->table; tables->arch;
tables++) { tables++) {
if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid)) if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
return tables->table; return &tables->table;
} }
return NULL; return NULL;
} }
...@@ -465,9 +470,9 @@ const struct pmu_event *find_core_events_table(const char *arch, const char *cpu ...@@ -465,9 +470,9 @@ const struct pmu_event *find_core_events_table(const char *arch, const char *cpu
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data)
{ {
for (const struct pmu_events_map *tables = &pmu_events_map[0]; for (const struct pmu_events_map *tables = &pmu_events_map[0];
tables->table; tables->arch;
tables++) { tables++) {
int ret = pmu_events_table_for_each_event(tables->table, fn, data); int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
...@@ -475,13 +480,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) ...@@ -475,13 +480,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data)
return 0; return 0;
} }
const struct pmu_event *find_sys_events_table(const char *name) const struct pmu_events_table *find_sys_events_table(const char *name)
{ {
for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0]; for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
tables->name; tables->name;
tables++) { tables++) {
if (!strcmp(tables->name, name)) if (!strcmp(tables->name, name))
return tables->table; return &tables->table;
} }
return NULL; return NULL;
} }
...@@ -491,7 +496,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data) ...@@ -491,7 +496,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data)
for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0]; for (const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
tables->name; tables->name;
tables++) { tables++) {
int ret = pmu_events_table_for_each_event(tables->table, fn, data); int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
......
...@@ -30,18 +30,20 @@ struct pmu_event { ...@@ -30,18 +30,20 @@ struct pmu_event {
const char *metric_constraint; const char *metric_constraint;
}; };
struct pmu_events_table;
typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe, typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe,
const struct pmu_event *table, const struct pmu_events_table *table,
void *data); void *data);
int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_event_iter_fn fn, int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
void *data); void *data);
const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu); const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu);
const struct pmu_event *find_core_events_table(const char *arch, const char *cpuid); const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data); int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
const struct pmu_event *find_sys_events_table(const char *name); const struct pmu_events_table *find_sys_events_table(const char *name);
int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data); int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data);
#endif #endif
...@@ -180,7 +180,7 @@ static int expand_metric_events(void) ...@@ -180,7 +180,7 @@ static int expand_metric_events(void)
struct evlist *evlist; struct evlist *evlist;
struct rblist metric_events; struct rblist metric_events;
const char metric_str[] = "CPI"; const char metric_str[] = "CPI";
const struct pmu_event *pme_test; const struct pmu_events_table *pme_test;
evlist = evlist__new(); evlist = evlist__new();
TEST_ASSERT_VAL("failed to get evlist", evlist); TEST_ASSERT_VAL("failed to get evlist", evlist);
......
...@@ -72,7 +72,7 @@ static int __compute_metric(const char *name, struct value *vals, ...@@ -72,7 +72,7 @@ static int __compute_metric(const char *name, struct value *vals,
struct rblist metric_events = { struct rblist metric_events = {
.nr_entries = 0, .nr_entries = 0,
}; };
const struct pmu_event *pme_test; const struct pmu_events_table *pme_test;
struct perf_cpu_map *cpus; struct perf_cpu_map *cpus;
struct runtime_stat st; struct runtime_stat st;
struct evlist *evlist; struct evlist *evlist;
......
...@@ -424,7 +424,7 @@ static int compare_alias_to_test_event(struct perf_pmu_alias *alias, ...@@ -424,7 +424,7 @@ static int compare_alias_to_test_event(struct perf_pmu_alias *alias,
} }
static int test__pmu_event_table_core_callback(const struct pmu_event *pe, static int test__pmu_event_table_core_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data) void *data)
{ {
int *map_events = data; int *map_events = data;
...@@ -461,7 +461,7 @@ static int test__pmu_event_table_core_callback(const struct pmu_event *pe, ...@@ -461,7 +461,7 @@ static int test__pmu_event_table_core_callback(const struct pmu_event *pe,
} }
static int test__pmu_event_table_sys_callback(const struct pmu_event *pe, static int test__pmu_event_table_sys_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data) void *data)
{ {
int *map_events = data; int *map_events = data;
...@@ -495,8 +495,8 @@ static int test__pmu_event_table_sys_callback(const struct pmu_event *pe, ...@@ -495,8 +495,8 @@ static int test__pmu_event_table_sys_callback(const struct pmu_event *pe,
static int test__pmu_event_table(struct test_suite *test __maybe_unused, static int test__pmu_event_table(struct test_suite *test __maybe_unused,
int subtest __maybe_unused) int subtest __maybe_unused)
{ {
const struct pmu_event *sys_event_table = find_sys_events_table("pme_test_soc_sys"); const struct pmu_events_table *sys_event_table = find_sys_events_table("pme_test_soc_sys");
const struct pmu_event *table = find_core_events_table("testarch", "testcpu"); const struct pmu_events_table *table = find_core_events_table("testarch", "testcpu");
int map_events = 0, expected_events, err; int map_events = 0, expected_events, err;
/* ignore 3x sentinels */ /* ignore 3x sentinels */
...@@ -544,7 +544,7 @@ static int __test_core_pmu_event_aliases(char *pmu_name, int *count) ...@@ -544,7 +544,7 @@ static int __test_core_pmu_event_aliases(char *pmu_name, int *count)
struct perf_pmu *pmu; struct perf_pmu *pmu;
LIST_HEAD(aliases); LIST_HEAD(aliases);
int res = 0; int res = 0;
const struct pmu_event *table = find_core_events_table("testarch", "testcpu"); const struct pmu_events_table *table = find_core_events_table("testarch", "testcpu");
struct perf_pmu_alias *a, *tmp; struct perf_pmu_alias *a, *tmp;
if (!table) if (!table)
...@@ -597,7 +597,7 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu) ...@@ -597,7 +597,7 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
struct perf_pmu *pmu = &test_pmu->pmu; struct perf_pmu *pmu = &test_pmu->pmu;
const char *pmu_name = pmu->name; const char *pmu_name = pmu->name;
struct perf_pmu_alias *a, *tmp, *alias; struct perf_pmu_alias *a, *tmp, *alias;
const struct pmu_event *events_table; const struct pmu_events_table *events_table;
LIST_HEAD(aliases); LIST_HEAD(aliases);
int res = 0; int res = 0;
...@@ -839,7 +839,7 @@ struct metric { ...@@ -839,7 +839,7 @@ struct metric {
struct metric_ref metric_ref; struct metric_ref metric_ref;
}; };
static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_event *table, static int test__parsing_callback(const struct pmu_event *pe, const struct pmu_events_table *table,
void *data) void *data)
{ {
int *failures = data; int *failures = data;
...@@ -1016,7 +1016,7 @@ static int metric_parse_fake(const char *str) ...@@ -1016,7 +1016,7 @@ static int metric_parse_fake(const char *str)
} }
static int test__parsing_fake_callback(const struct pmu_event *pe, static int test__parsing_fake_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data __maybe_unused) void *data __maybe_unused)
{ {
if (!pe->metric_expr) if (!pe->metric_expr)
......
...@@ -508,7 +508,7 @@ struct metricgroup_iter_data { ...@@ -508,7 +508,7 @@ struct metricgroup_iter_data {
}; };
static int metricgroup__sys_event_iter(const struct pmu_event *pe, static int metricgroup__sys_event_iter(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table,
void *data) void *data)
{ {
struct metricgroup_iter_data *d = data; struct metricgroup_iter_data *d = data;
...@@ -529,7 +529,7 @@ static int metricgroup__sys_event_iter(const struct pmu_event *pe, ...@@ -529,7 +529,7 @@ static int metricgroup__sys_event_iter(const struct pmu_event *pe,
} }
static int metricgroup__print_sys_event_iter(const struct pmu_event *pe, static int metricgroup__print_sys_event_iter(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data) void *data)
{ {
struct metricgroup_print_sys_idata *d = data; struct metricgroup_print_sys_idata *d = data;
...@@ -549,7 +549,7 @@ struct metricgroup_print_data { ...@@ -549,7 +549,7 @@ struct metricgroup_print_data {
}; };
static int metricgroup__print_callback(const struct pmu_event *pe, static int metricgroup__print_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct metricgroup_print_data *data = vdata; struct metricgroup_print_data *data = vdata;
...@@ -571,7 +571,7 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter, ...@@ -571,7 +571,7 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
struct rblist groups; struct rblist groups;
struct rb_node *node, *next; struct rb_node *node, *next;
struct strlist *metriclist = NULL; struct strlist *metriclist = NULL;
const struct pmu_event *table; const struct pmu_events_table *table;
if (!metricgroups) { if (!metricgroups) {
metriclist = strlist__new(NULL, NULL); metriclist = strlist__new(NULL, NULL);
...@@ -876,7 +876,7 @@ struct metricgroup_add_iter_data { ...@@ -876,7 +876,7 @@ struct metricgroup_add_iter_data {
bool metric_no_group; bool metric_no_group;
struct metric *root_metric; struct metric *root_metric;
const struct visited_metric *visited; const struct visited_metric *visited;
const struct pmu_event *table; const struct pmu_events_table *table;
}; };
static int add_metric(struct list_head *metric_list, static int add_metric(struct list_head *metric_list,
...@@ -885,7 +885,7 @@ static int add_metric(struct list_head *metric_list, ...@@ -885,7 +885,7 @@ static int add_metric(struct list_head *metric_list,
bool metric_no_group, bool metric_no_group,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_event *table); const struct pmu_events_table *table);
/** /**
* resolve_metric - Locate metrics within the root metric and recursively add * resolve_metric - Locate metrics within the root metric and recursively add
...@@ -908,7 +908,7 @@ static int resolve_metric(struct list_head *metric_list, ...@@ -908,7 +908,7 @@ static int resolve_metric(struct list_head *metric_list,
bool metric_no_group, bool metric_no_group,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
struct hashmap_entry *cur; struct hashmap_entry *cur;
size_t bkt; size_t bkt;
...@@ -986,7 +986,7 @@ static int __add_metric(struct list_head *metric_list, ...@@ -986,7 +986,7 @@ static int __add_metric(struct list_head *metric_list,
int runtime, int runtime,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
const struct visited_metric *vm; const struct visited_metric *vm;
int ret; int ret;
...@@ -1077,7 +1077,7 @@ struct metricgroup__find_metric_data { ...@@ -1077,7 +1077,7 @@ struct metricgroup__find_metric_data {
}; };
static int metricgroup__find_metric_callback(const struct pmu_event *pe, static int metricgroup__find_metric_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct metricgroup__find_metric_data *data = vdata; struct metricgroup__find_metric_data *data = vdata;
...@@ -1090,7 +1090,7 @@ static int metricgroup__find_metric_callback(const struct pmu_event *pe, ...@@ -1090,7 +1090,7 @@ static int metricgroup__find_metric_callback(const struct pmu_event *pe,
} }
const struct pmu_event *metricgroup__find_metric(const char *metric, const struct pmu_event *metricgroup__find_metric(const char *metric,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
struct metricgroup__find_metric_data data = { struct metricgroup__find_metric_data data = {
.metric = metric, .metric = metric,
...@@ -1108,7 +1108,7 @@ static int add_metric(struct list_head *metric_list, ...@@ -1108,7 +1108,7 @@ static int add_metric(struct list_head *metric_list,
bool metric_no_group, bool metric_no_group,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
int ret = 0; int ret = 0;
...@@ -1136,8 +1136,8 @@ static int add_metric(struct list_head *metric_list, ...@@ -1136,8 +1136,8 @@ static int add_metric(struct list_head *metric_list,
} }
static int metricgroup__add_metric_sys_event_iter(const struct pmu_event *pe, static int metricgroup__add_metric_sys_event_iter(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data) void *data)
{ {
struct metricgroup_add_iter_data *d = data; struct metricgroup_add_iter_data *d = data;
int ret; int ret;
...@@ -1193,7 +1193,7 @@ struct metricgroup__add_metric_data { ...@@ -1193,7 +1193,7 @@ struct metricgroup__add_metric_data {
}; };
static int metricgroup__add_metric_callback(const struct pmu_event *pe, static int metricgroup__add_metric_callback(const struct pmu_event *pe,
const struct pmu_event *table, const struct pmu_events_table *table,
void *vdata) void *vdata)
{ {
struct metricgroup__add_metric_data *data = vdata; struct metricgroup__add_metric_data *data = vdata;
...@@ -1227,7 +1227,7 @@ static int metricgroup__add_metric_callback(const struct pmu_event *pe, ...@@ -1227,7 +1227,7 @@ static int metricgroup__add_metric_callback(const struct pmu_event *pe,
static int metricgroup__add_metric(const char *metric_name, const char *modifier, static int metricgroup__add_metric(const char *metric_name, const char *modifier,
bool metric_no_group, bool metric_no_group,
struct list_head *metric_list, struct list_head *metric_list,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
LIST_HEAD(list); LIST_HEAD(list);
int ret; int ret;
...@@ -1296,7 +1296,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier ...@@ -1296,7 +1296,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier
*/ */
static int metricgroup__add_metric_list(const char *list, bool metric_no_group, static int metricgroup__add_metric_list(const char *list, bool metric_no_group,
struct list_head *metric_list, struct list_head *metric_list,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
char *list_itr, *list_copy, *metric_name, *modifier; char *list_itr, *list_copy, *metric_name, *modifier;
int ret, count = 0; int ret, count = 0;
...@@ -1504,7 +1504,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str, ...@@ -1504,7 +1504,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str,
bool metric_no_merge, bool metric_no_merge,
struct perf_pmu *fake_pmu, struct perf_pmu *fake_pmu,
struct rblist *metric_events_list, struct rblist *metric_events_list,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
struct evlist *combined_evlist = NULL; struct evlist *combined_evlist = NULL;
LIST_HEAD(metric_list); LIST_HEAD(metric_list);
...@@ -1650,14 +1650,14 @@ int metricgroup__parse_groups(const struct option *opt, ...@@ -1650,14 +1650,14 @@ int metricgroup__parse_groups(const struct option *opt,
struct rblist *metric_events) struct rblist *metric_events)
{ {
struct evlist *perf_evlist = *(struct evlist **)opt->value; struct evlist *perf_evlist = *(struct evlist **)opt->value;
const struct pmu_event *table = pmu_events_table__find(); const struct pmu_events_table *table = pmu_events_table__find();
return parse_groups(perf_evlist, str, metric_no_group, return parse_groups(perf_evlist, str, metric_no_group,
metric_no_merge, NULL, metric_events, table); metric_no_merge, NULL, metric_events, table);
} }
int metricgroup__parse_groups_test(struct evlist *evlist, int metricgroup__parse_groups_test(struct evlist *evlist,
const struct pmu_event *table, const struct pmu_events_table *table,
const char *str, const char *str,
bool metric_no_group, bool metric_no_group,
bool metric_no_merge, bool metric_no_merge,
...@@ -1668,7 +1668,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist, ...@@ -1668,7 +1668,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist,
} }
static int metricgroup__has_metric_callback(const struct pmu_event *pe, static int metricgroup__has_metric_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
const char *metric = vdata; const char *metric = vdata;
...@@ -1684,7 +1684,7 @@ static int metricgroup__has_metric_callback(const struct pmu_event *pe, ...@@ -1684,7 +1684,7 @@ static int metricgroup__has_metric_callback(const struct pmu_event *pe,
bool metricgroup__has_metric(const char *metric) bool metricgroup__has_metric(const char *metric)
{ {
const struct pmu_event *table = pmu_events_table__find(); const struct pmu_events_table *table = pmu_events_table__find();
if (!table) if (!table)
return false; return false;
......
...@@ -11,7 +11,6 @@ struct evlist; ...@@ -11,7 +11,6 @@ struct evlist;
struct evsel; struct evsel;
struct option; struct option;
struct rblist; struct rblist;
struct pmu_events_map;
struct cgroup; struct cgroup;
/** /**
...@@ -71,9 +70,9 @@ int metricgroup__parse_groups(const struct option *opt, ...@@ -71,9 +70,9 @@ int metricgroup__parse_groups(const struct option *opt,
bool metric_no_merge, bool metric_no_merge,
struct rblist *metric_events); struct rblist *metric_events);
const struct pmu_event *metricgroup__find_metric(const char *metric, const struct pmu_event *metricgroup__find_metric(const char *metric,
const struct pmu_event *table); const struct pmu_events_table *table);
int metricgroup__parse_groups_test(struct evlist *evlist, int metricgroup__parse_groups_test(struct evlist *evlist,
const struct pmu_event *table, const struct pmu_events_table *table,
const char *str, const char *str,
bool metric_no_group, bool metric_no_group,
bool metric_no_merge, bool metric_no_merge,
......
...@@ -710,7 +710,7 @@ char *perf_pmu__getcpuid(struct perf_pmu *pmu) ...@@ -710,7 +710,7 @@ char *perf_pmu__getcpuid(struct perf_pmu *pmu)
return cpuid; return cpuid;
} }
__weak const struct pmu_event *pmu_events_table__find(void) __weak const struct pmu_events_table *pmu_events_table__find(void)
{ {
return perf_pmu__find_table(NULL); return perf_pmu__find_table(NULL);
} }
...@@ -799,7 +799,7 @@ struct pmu_add_cpu_aliases_map_data { ...@@ -799,7 +799,7 @@ struct pmu_add_cpu_aliases_map_data {
}; };
static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe, static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct pmu_add_cpu_aliases_map_data *data = vdata; struct pmu_add_cpu_aliases_map_data *data = vdata;
...@@ -827,7 +827,7 @@ static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe, ...@@ -827,7 +827,7 @@ static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
* as aliases. * as aliases.
*/ */
void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu, void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
const struct pmu_event *table) const struct pmu_events_table *table)
{ {
struct pmu_add_cpu_aliases_map_data data = { struct pmu_add_cpu_aliases_map_data data = {
.head = head, .head = head,
...@@ -841,7 +841,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu, ...@@ -841,7 +841,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu) static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
{ {
const struct pmu_event *table; const struct pmu_events_table *table;
table = perf_pmu__find_table(pmu); table = perf_pmu__find_table(pmu);
if (!table) if (!table)
...@@ -856,7 +856,7 @@ struct pmu_sys_event_iter_data { ...@@ -856,7 +856,7 @@ struct pmu_sys_event_iter_data {
}; };
static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe, static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *data) void *data)
{ {
struct pmu_sys_event_iter_data *idata = data; struct pmu_sys_event_iter_data *idata = data;
......
...@@ -126,10 +126,10 @@ int perf_pmu__test(void); ...@@ -126,10 +126,10 @@ int perf_pmu__test(void);
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu, void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
const struct pmu_event *table); const struct pmu_events_table *table);
char *perf_pmu__getcpuid(struct perf_pmu *pmu); char *perf_pmu__getcpuid(struct perf_pmu *pmu);
const struct pmu_event *pmu_events_table__find(void); const struct pmu_events_table *pmu_events_table__find(void);
bool pmu_uncore_alias_match(const char *pmu_name, const char *name); bool pmu_uncore_alias_match(const char *pmu_name, const char *name);
void perf_pmu_free_alias(struct perf_pmu_alias *alias); void perf_pmu_free_alias(struct perf_pmu_alias *alias);
......
...@@ -135,7 +135,7 @@ struct get_counter_name_data { ...@@ -135,7 +135,7 @@ struct get_counter_name_data {
}; };
static int get_counter_name_callback(const struct pmu_event *evp, static int get_counter_name_callback(const struct pmu_event *evp,
const struct pmu_event *table __maybe_unused, const struct pmu_events_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct get_counter_name_data *data = vdata; struct get_counter_name_data *data = vdata;
...@@ -157,7 +157,7 @@ static int get_counter_name_callback(const struct pmu_event *evp, ...@@ -157,7 +157,7 @@ static int get_counter_name_callback(const struct pmu_event *evp,
* the name of this counter. * the name of this counter.
* If no match is found a NULL pointer is returned. * If no match is found a NULL pointer is returned.
*/ */
static const char *get_counter_name(int set, int nr, const struct pmu_event *table) static const char *get_counter_name(int set, int nr, const struct pmu_events_table *table)
{ {
struct get_counter_name_data data = { struct get_counter_name_data data = {
.wanted = get_counterset_start(set) + nr, .wanted = get_counterset_start(set) + nr,
...@@ -177,7 +177,7 @@ static void s390_cpumcfdg_dump(struct perf_sample *sample) ...@@ -177,7 +177,7 @@ static void s390_cpumcfdg_dump(struct perf_sample *sample)
unsigned char *buf = sample->raw_data; unsigned char *buf = sample->raw_data;
const char *color = PERF_COLOR_BLUE; const char *color = PERF_COLOR_BLUE;
struct cf_ctrset_entry *cep, ce; struct cf_ctrset_entry *cep, ce;
const struct pmu_event *table; const struct pmu_events_table *table;
u64 *p; u64 *p;
table = pmu_events_table__find(); table = pmu_events_table__find();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment