diff options
author | Ian Rogers <[email protected]> | 2021-10-15 10:21:19 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2021-10-20 10:34:53 -0300 |
commit | a3de76903dd0786a8661e9e6eb9054a7519e10e7 (patch) | |
tree | 0e1e4f98026fca0efe7a76b39047a0c165e686f4 | |
parent | 3d81d761a518c6f5d5a084a7356470d5dbb0d870 (diff) |
perf metric: Only add a referenced metric once
If a metric references other metrics then the same other metrics may be
referenced more than once, but the events and metric ref are only needed
once.
An example of this is in tests/parse-metric.c where DCache_L2_Hits
references the metric DCache_L2_All_Hits twice, once directly and once
through DCache_L2_All.
Signed-off-by: Ian Rogers <[email protected]>
Acked-by: Andi Kleen <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Antonov <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andrew Kilroy <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Changbin Du <[email protected]>
Cc: Denys Zagorui <[email protected]>
Cc: Fabian Hemmer <[email protected]>
Cc: Felix Fietkau <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jacob Keller <[email protected]>
Cc: Jiapeng Chong <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Joakim Zhang <[email protected]>
Cc: John Garry <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Kees Kook <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Nicholas Fraser <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Paul Clarke <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Riccardo Mancini <[email protected]>
Cc: Sami Tolvanen <[email protected]>
Cc: ShihCheng Tu <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Sumanth Korikkar <[email protected]>
Cc: Thomas Richter <[email protected]>
Cc: Wan Jiabing <[email protected]>
Cc: Zhen Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/metricgroup.c | 12 |
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; |