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

perf pmu-events: Introduce pmu_metrics_table

Add a metrics table that is just a cast from pmu_events_table. This
changes the APIs so that event and metric usage of the underlying
table is different. For the no jevents case the tables are already
separate, later changes will separate the tables for the jevents case.
Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
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: Caleb Biggers <caleb.biggers@intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kang Minchul <tegongkang@gmail.com>
Cc: Kim Phillips <kim.phillips@amd.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: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@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
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230126233645.200509-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9f587cc9
...@@ -23,6 +23,15 @@ static struct perf_pmu *pmu__find_core_pmu(void) ...@@ -23,6 +23,15 @@ static struct perf_pmu *pmu__find_core_pmu(void)
return pmu; return pmu;
} }
return NULL;
}
const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
struct perf_pmu *pmu = pmu__find_core_pmu();
if (pmu)
return perf_pmu__find_metrics_table(pmu);
return NULL; return NULL;
} }
......
...@@ -278,13 +278,11 @@ int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_ev ...@@ -278,13 +278,11 @@ int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_ev
return 0; return 0;
} }
int pmu_events_table_for_each_metric(const struct pmu_events_table *etable, pmu_metric_iter_fn fn, int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
void *data) void *data)
{ {
struct pmu_metrics_table *table = (struct pmu_metrics_table *)etable;
for (const struct pmu_metric *pm = &table->entries[0]; pm->metric_expr; pm++) { for (const struct pmu_metric *pm = &table->entries[0]; pm->metric_expr; pm++) {
int ret = fn(pm, etable, data); int ret = fn(pm, table, data);
if (ret) if (ret)
return ret; return ret;
...@@ -320,9 +318,9 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) ...@@ -320,9 +318,9 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
return table; return table;
} }
const struct pmu_events_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu) const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu)
{ {
const struct pmu_events_table *table = NULL; const struct pmu_metrics_table *table = NULL;
char *cpuid = perf_pmu__getcpuid(pmu); char *cpuid = perf_pmu__getcpuid(pmu);
int i; int i;
...@@ -340,7 +338,7 @@ const struct pmu_events_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu ...@@ -340,7 +338,7 @@ const struct pmu_events_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu
break; break;
if (!strcmp_cpuid_str(map->cpuid, cpuid)) { if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
table = (const struct pmu_events_table *)&map->metric_table; table = &map->metric_table;
break; break;
} }
} }
...@@ -359,13 +357,13 @@ const struct pmu_events_table *find_core_events_table(const char *arch, const ch ...@@ -359,13 +357,13 @@ const struct pmu_events_table *find_core_events_table(const char *arch, const ch
return NULL; return NULL;
} }
const struct pmu_events_table *find_core_metrics_table(const char *arch, const char *cpuid) const struct pmu_metrics_table *find_core_metrics_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->arch; 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 (const struct pmu_events_table *)&tables->metric_table; return &tables->metric_table;
} }
return NULL; return NULL;
} }
...@@ -386,8 +384,7 @@ int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data) ...@@ -386,8 +384,7 @@ int pmu_for_each_core_metric(pmu_metric_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->arch; tables->arch;
tables++) { tables++) {
int ret = pmu_events_table_for_each_metric( int ret = pmu_metrics_table_for_each_metric(&tables->metric_table, fn, data);
(const struct pmu_events_table *)&tables->metric_table, fn, data);
if (ret) if (ret)
return ret; return ret;
......
...@@ -611,10 +611,12 @@ int pmu_events_table_for_each_event(const struct pmu_events_table *table, ...@@ -611,10 +611,12 @@ int pmu_events_table_for_each_event(const struct pmu_events_table *table,
return 0; return 0;
} }
int pmu_events_table_for_each_metric(const struct pmu_events_table *table, int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *mtable,
pmu_metric_iter_fn fn, pmu_metric_iter_fn fn,
void *data) void *data)
{ {
const struct pmu_events_table *table = (const struct pmu_events_table *)mtable;
for (size_t i = 0; i < table->length; i++) { for (size_t i = 0; i < table->length; i++) {
struct pmu_metric pm; struct pmu_metric pm;
int ret; int ret;
...@@ -622,7 +624,7 @@ int pmu_events_table_for_each_metric(const struct pmu_events_table *table, ...@@ -622,7 +624,7 @@ int pmu_events_table_for_each_metric(const struct pmu_events_table *table,
decompress_metric(table->entries[i].offset, &pm); decompress_metric(table->entries[i].offset, &pm);
if (!pm.metric_expr) if (!pm.metric_expr)
continue; continue;
ret = fn(&pm, table, data); ret = fn(&pm, mtable, data);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -656,6 +658,11 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) ...@@ -656,6 +658,11 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
return table; return table;
} }
const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu)
{
return (struct pmu_metrics_table *)perf_pmu__find_events_table(pmu);
}
const struct pmu_events_table *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];
...@@ -667,9 +674,9 @@ const struct pmu_events_table *find_core_events_table(const char *arch, const ch ...@@ -667,9 +674,9 @@ const struct pmu_events_table *find_core_events_table(const char *arch, const ch
return NULL; return NULL;
} }
const struct pmu_events_table *find_core_metrics_table(const char *arch, const char *cpuid) const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid)
{ {
return (struct pmu_events_table *)find_core_events_table(arch, cpuid); return (struct pmu_metrics_table *)find_core_events_table(arch, 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)
...@@ -690,7 +697,8 @@ int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data) ...@@ -690,7 +697,8 @@ int pmu_for_each_core_metric(pmu_metric_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->arch; tables->arch;
tables++) { tables++) {
int ret = pmu_events_table_for_each_metric(&tables->table, fn, data); int ret = pmu_metrics_table_for_each_metric(
(struct pmu_metrics_table *)&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
...@@ -727,7 +735,8 @@ int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data) ...@@ -727,7 +735,8 @@ int pmu_for_each_sys_metric(pmu_metric_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_metric(&tables->table, fn, data); int ret = pmu_metrics_table_for_each_metric(
(struct pmu_metrics_table *)&tables->table, fn, data);
if (ret) if (ret)
return ret; return ret;
......
...@@ -39,28 +39,30 @@ struct pmu_metric { ...@@ -39,28 +39,30 @@ struct pmu_metric {
}; };
struct pmu_events_table; struct pmu_events_table;
struct pmu_metrics_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_events_table *table, const struct pmu_events_table *table,
void *data); void *data);
typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm, typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
void *data); void *data);
int pmu_events_table_for_each_event(const struct pmu_events_table *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);
int pmu_events_table_for_each_metric(const struct pmu_events_table *table, pmu_metric_iter_fn fn, int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
void *data); void *data);
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu); const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu);
const struct pmu_events_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu); const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu);
const struct pmu_events_table *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);
const struct pmu_events_table *find_core_metrics_table(const char *arch, const char *cpuid); const struct pmu_metrics_table *find_core_metrics_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);
int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data); int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data);
const struct pmu_events_table *find_sys_events_table(const char *name); const struct pmu_events_table *find_sys_events_table(const char *name);
const struct pmu_metrics_table *find_sys_metrics_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);
int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data); int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data);
......
...@@ -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_events_table *pme_test; const struct pmu_metrics_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_events_table *pme_test; const struct pmu_metrics_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;
......
...@@ -813,7 +813,8 @@ struct metric { ...@@ -813,7 +813,8 @@ struct metric {
struct metric_ref metric_ref; struct metric_ref metric_ref;
}; };
static int test__parsing_callback(const struct pmu_metric *pm, const struct pmu_events_table *table, static int test__parsing_callback(const struct pmu_metric *pm,
const struct pmu_metrics_table *table,
void *data) void *data)
{ {
int *failures = data; int *failures = data;
...@@ -995,7 +996,7 @@ static int metric_parse_fake(const char *metric_name, const char *str) ...@@ -995,7 +996,7 @@ static int metric_parse_fake(const char *metric_name, const char *str)
} }
static int test__parsing_fake_callback(const struct pmu_metric *pm, static int test__parsing_fake_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused, const struct pmu_metrics_table *table __maybe_unused,
void *data __maybe_unused) void *data __maybe_unused)
{ {
return metric_parse_fake(pm->metric_name, pm->metric_expr); return metric_parse_fake(pm->metric_name, pm->metric_expr);
......
...@@ -457,7 +457,7 @@ struct metricgroup_iter_data { ...@@ -457,7 +457,7 @@ struct metricgroup_iter_data {
}; };
static int metricgroup__sys_event_iter(const struct pmu_metric *pm, static int metricgroup__sys_event_iter(const struct pmu_metric *pm,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
void *data) void *data)
{ {
struct metricgroup_iter_data *d = data; struct metricgroup_iter_data *d = data;
...@@ -477,7 +477,7 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm, ...@@ -477,7 +477,7 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm,
} }
static int metricgroup__add_to_mep_groups_callback(const struct pmu_metric *pm, static int metricgroup__add_to_mep_groups_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused, const struct pmu_metrics_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct rblist *groups = vdata; struct rblist *groups = vdata;
...@@ -488,16 +488,16 @@ static int metricgroup__add_to_mep_groups_callback(const struct pmu_metric *pm, ...@@ -488,16 +488,16 @@ static int metricgroup__add_to_mep_groups_callback(const struct pmu_metric *pm,
void metricgroup__print(const struct print_callbacks *print_cb, void *print_state) void metricgroup__print(const struct print_callbacks *print_cb, void *print_state)
{ {
struct rblist groups; struct rblist groups;
const struct pmu_events_table *table; const struct pmu_metrics_table *table;
struct rb_node *node, *next; struct rb_node *node, *next;
rblist__init(&groups); rblist__init(&groups);
groups.node_new = mep_new; groups.node_new = mep_new;
groups.node_cmp = mep_cmp; groups.node_cmp = mep_cmp;
groups.node_delete = mep_delete; groups.node_delete = mep_delete;
table = pmu_events_table__find(); table = pmu_metrics_table__find();
if (table) { if (table) {
pmu_events_table_for_each_metric(table, pmu_metrics_table_for_each_metric(table,
metricgroup__add_to_mep_groups_callback, metricgroup__add_to_mep_groups_callback,
&groups); &groups);
} }
...@@ -765,11 +765,11 @@ struct metricgroup_add_iter_data { ...@@ -765,11 +765,11 @@ struct metricgroup_add_iter_data {
bool system_wide; bool system_wide;
struct metric *root_metric; struct metric *root_metric;
const struct visited_metric *visited; const struct visited_metric *visited;
const struct pmu_events_table *table; const struct pmu_metrics_table *table;
}; };
static bool metricgroup__find_metric(const char *metric, static bool metricgroup__find_metric(const char *metric,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
struct pmu_metric *pm); struct pmu_metric *pm);
static int add_metric(struct list_head *metric_list, static int add_metric(struct list_head *metric_list,
...@@ -780,7 +780,7 @@ static int add_metric(struct list_head *metric_list, ...@@ -780,7 +780,7 @@ static int add_metric(struct list_head *metric_list,
bool system_wide, bool system_wide,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_events_table *table); const struct pmu_metrics_table *table);
/** /**
* resolve_metric - Locate metrics within the root metric and recursively add * resolve_metric - Locate metrics within the root metric and recursively add
...@@ -807,7 +807,7 @@ static int resolve_metric(struct list_head *metric_list, ...@@ -807,7 +807,7 @@ static int resolve_metric(struct list_head *metric_list,
bool system_wide, bool system_wide,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_events_table *table) const struct pmu_metrics_table *table)
{ {
struct hashmap_entry *cur; struct hashmap_entry *cur;
size_t bkt; size_t bkt;
...@@ -889,7 +889,7 @@ static int __add_metric(struct list_head *metric_list, ...@@ -889,7 +889,7 @@ static int __add_metric(struct list_head *metric_list,
bool system_wide, bool system_wide,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_events_table *table) const struct pmu_metrics_table *table)
{ {
const struct visited_metric *vm; const struct visited_metric *vm;
int ret; int ret;
...@@ -982,7 +982,7 @@ struct metricgroup__find_metric_data { ...@@ -982,7 +982,7 @@ struct metricgroup__find_metric_data {
}; };
static int metricgroup__find_metric_callback(const struct pmu_metric *pm, static int metricgroup__find_metric_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused, const struct pmu_metrics_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
struct metricgroup__find_metric_data *data = vdata; struct metricgroup__find_metric_data *data = vdata;
...@@ -995,7 +995,7 @@ static int metricgroup__find_metric_callback(const struct pmu_metric *pm, ...@@ -995,7 +995,7 @@ static int metricgroup__find_metric_callback(const struct pmu_metric *pm,
} }
static bool metricgroup__find_metric(const char *metric, static bool metricgroup__find_metric(const char *metric,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
struct pmu_metric *pm) struct pmu_metric *pm)
{ {
struct metricgroup__find_metric_data data = { struct metricgroup__find_metric_data data = {
...@@ -1003,7 +1003,7 @@ static bool metricgroup__find_metric(const char *metric, ...@@ -1003,7 +1003,7 @@ static bool metricgroup__find_metric(const char *metric,
.pm = pm, .pm = pm,
}; };
return pmu_events_table_for_each_metric(table, metricgroup__find_metric_callback, &data) return pmu_metrics_table_for_each_metric(table, metricgroup__find_metric_callback, &data)
? true : false; ? true : false;
} }
...@@ -1015,7 +1015,7 @@ static int add_metric(struct list_head *metric_list, ...@@ -1015,7 +1015,7 @@ static int add_metric(struct list_head *metric_list,
bool system_wide, bool system_wide,
struct metric *root_metric, struct metric *root_metric,
const struct visited_metric *visited, const struct visited_metric *visited,
const struct pmu_events_table *table) const struct pmu_metrics_table *table)
{ {
int ret = 0; int ret = 0;
...@@ -1045,7 +1045,7 @@ static int add_metric(struct list_head *metric_list, ...@@ -1045,7 +1045,7 @@ static int add_metric(struct list_head *metric_list,
} }
static int metricgroup__add_metric_sys_event_iter(const struct pmu_metric *pm, static int metricgroup__add_metric_sys_event_iter(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused, const struct pmu_metrics_table *table __maybe_unused,
void *data) void *data)
{ {
struct metricgroup_add_iter_data *d = data; struct metricgroup_add_iter_data *d = data;
...@@ -1105,7 +1105,7 @@ struct metricgroup__add_metric_data { ...@@ -1105,7 +1105,7 @@ struct metricgroup__add_metric_data {
}; };
static int metricgroup__add_metric_callback(const struct pmu_metric *pm, static int metricgroup__add_metric_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
void *vdata) void *vdata)
{ {
struct metricgroup__add_metric_data *data = vdata; struct metricgroup__add_metric_data *data = vdata;
...@@ -1143,7 +1143,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier ...@@ -1143,7 +1143,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier
const char *user_requested_cpu_list, const char *user_requested_cpu_list,
bool system_wide, bool system_wide,
struct list_head *metric_list, struct list_head *metric_list,
const struct pmu_events_table *table) const struct pmu_metrics_table *table)
{ {
LIST_HEAD(list); LIST_HEAD(list);
int ret; int ret;
...@@ -1163,7 +1163,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier ...@@ -1163,7 +1163,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier
* Iterate over all metrics seeing if metric matches either the * Iterate over all metrics seeing if metric matches either the
* name or group. When it does add the metric to the list. * name or group. When it does add the metric to the list.
*/ */
ret = pmu_events_table_for_each_metric(table, metricgroup__add_metric_callback, ret = pmu_metrics_table_for_each_metric(table, metricgroup__add_metric_callback,
&data); &data);
if (ret) if (ret)
goto out; goto out;
...@@ -1219,7 +1219,7 @@ static int metricgroup__add_metric(const char *metric_name, const char *modifier ...@@ -1219,7 +1219,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,
const char *user_requested_cpu_list, const char *user_requested_cpu_list,
bool system_wide, struct list_head *metric_list, bool system_wide, struct list_head *metric_list,
const struct pmu_events_table *table) const struct pmu_metrics_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;
...@@ -1429,7 +1429,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str, ...@@ -1429,7 +1429,7 @@ static int parse_groups(struct evlist *perf_evlist, const char *str,
bool system_wide, bool system_wide,
struct perf_pmu *fake_pmu, struct perf_pmu *fake_pmu,
struct rblist *metric_events_list, struct rblist *metric_events_list,
const struct pmu_events_table *table) const struct pmu_metrics_table *table)
{ {
struct evlist *combined_evlist = NULL; struct evlist *combined_evlist = NULL;
LIST_HEAD(metric_list); LIST_HEAD(metric_list);
...@@ -1577,7 +1577,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, ...@@ -1577,7 +1577,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,
bool system_wide, bool system_wide,
struct rblist *metric_events) struct rblist *metric_events)
{ {
const struct pmu_events_table *table = pmu_events_table__find(); const struct pmu_metrics_table *table = pmu_metrics_table__find();
if (!table) if (!table)
return -EINVAL; return -EINVAL;
...@@ -1588,7 +1588,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, ...@@ -1588,7 +1588,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,
} }
int metricgroup__parse_groups_test(struct evlist *evlist, int metricgroup__parse_groups_test(struct evlist *evlist,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
const char *str, const char *str,
bool metric_no_group, bool metric_no_group,
bool metric_no_merge, bool metric_no_merge,
...@@ -1601,7 +1601,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist, ...@@ -1601,7 +1601,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist,
} }
static int metricgroup__has_metric_callback(const struct pmu_metric *pm, static int metricgroup__has_metric_callback(const struct pmu_metric *pm,
const struct pmu_events_table *table __maybe_unused, const struct pmu_metrics_table *table __maybe_unused,
void *vdata) void *vdata)
{ {
const char *metric = vdata; const char *metric = vdata;
...@@ -1617,12 +1617,12 @@ static int metricgroup__has_metric_callback(const struct pmu_metric *pm, ...@@ -1617,12 +1617,12 @@ static int metricgroup__has_metric_callback(const struct pmu_metric *pm,
bool metricgroup__has_metric(const char *metric) bool metricgroup__has_metric(const char *metric)
{ {
const struct pmu_events_table *table = pmu_events_table__find(); const struct pmu_metrics_table *table = pmu_metrics_table__find();
if (!table) if (!table)
return false; return false;
return pmu_events_table_for_each_metric(table, metricgroup__has_metric_callback, return pmu_metrics_table_for_each_metric(table, metricgroup__has_metric_callback,
(void *)metric) ? true : false; (void *)metric) ? true : false;
} }
......
...@@ -73,7 +73,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist, ...@@ -73,7 +73,7 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,
bool system_wide, bool system_wide,
struct rblist *metric_events); struct rblist *metric_events);
int metricgroup__parse_groups_test(struct evlist *evlist, int metricgroup__parse_groups_test(struct evlist *evlist,
const struct pmu_events_table *table, const struct pmu_metrics_table *table,
const char *str, const char *str,
bool metric_no_group, bool metric_no_group,
bool metric_no_merge, bool metric_no_merge,
......
...@@ -655,6 +655,11 @@ __weak const struct pmu_events_table *pmu_events_table__find(void) ...@@ -655,6 +655,11 @@ __weak const struct pmu_events_table *pmu_events_table__find(void)
return perf_pmu__find_events_table(NULL); return perf_pmu__find_events_table(NULL);
} }
__weak const struct pmu_metrics_table *pmu_metrics_table__find(void)
{
return perf_pmu__find_metrics_table(NULL);
}
/* /*
* Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name * Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name
* to be valid. * to be valid.
......
...@@ -231,6 +231,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu, ...@@ -231,6 +231,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
char *perf_pmu__getcpuid(struct perf_pmu *pmu); char *perf_pmu__getcpuid(struct perf_pmu *pmu);
const struct pmu_events_table *pmu_events_table__find(void); const struct pmu_events_table *pmu_events_table__find(void);
const struct pmu_metrics_table *pmu_metrics_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);
......
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