Commit a29c164a authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf metric: Add add_metric function

Decouple metric adding logging into add_metric function,
so it can be used from other places in following changes.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200719181320.785305-7-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ce391940
......@@ -625,27 +625,19 @@ static int __metricgroup__add_metric(struct list_head *group_list,
(match_metric(__pe->metric_group, __metric) || \
match_metric(__pe->metric_name, __metric)))
static int metricgroup__add_metric(const char *metric, bool metric_no_group,
struct strbuf *events,
struct list_head *group_list,
struct pmu_events_map *map)
static int add_metric(struct list_head *group_list,
struct pmu_event *pe,
bool metric_no_group)
{
struct pmu_event *pe;
struct egroup *eg;
int i, ret;
bool has_match = false;
int ret = 0;
map_for_each_metric(pe, i, map, metric) {
pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name);
has_match = true;
if (!strstr(pe->metric_expr, "?")) {
ret = __metricgroup__add_metric(group_list,
pe,
metric_no_group,
1);
if (ret)
return ret;
} else {
int j, count;
......@@ -656,14 +648,32 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group,
* those events to group_list.
*/
for (j = 0; j < count; j++) {
for (j = 0; j < count && !ret; j++) {
ret = __metricgroup__add_metric(
group_list, pe,
metric_no_group, j);
if (ret)
return ret;
}
}
return ret;
}
static int metricgroup__add_metric(const char *metric, bool metric_no_group,
struct strbuf *events,
struct list_head *group_list,
struct pmu_events_map *map)
{
struct pmu_event *pe;
struct egroup *eg;
int i, ret;
bool has_match = false;
map_for_each_metric(pe, i, map, metric) {
has_match = true;
ret = add_metric(group_list, pe, metric_no_group);
if (ret)
return ret;
}
/* End of pmu events. */
......
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