summaryrefslogtreecommitdiff
path: root/tools/perf/util/metricgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/metricgroup.c')
-rw-r--r--tools/perf/util/metricgroup.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index e4ce19389258..6c4c51e35aa7 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -870,12 +870,18 @@ static int __add_metric(struct list_head *metric_list,
*mp = m;
} else {
/*
- * We got here for the referenced metric, via the
- * recursive metricgroup__add_metric call, add
- * it to the parent group.
+ * This metric was referenced in a metric higher in the
+ * tree. Check if the same metric is already resolved in the
+ * metric_refs list.
*/
m = *mp;
+ list_for_each_entry(ref, &m->metric_refs, list) {
+ if (!strcmp(pe->metric_name, ref->metric_name))
+ return 0;
+ }
+
+ /*Add the new referenced metric to the pare the parent group. */
ref = malloc(sizeof(*ref));
if (!ref)
return -ENOMEM;