From c2605dd49acf110bcb59df2ad07b1353cbf8dd6c Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 19 Jul 2020 20:13:13 +0200 Subject: [PATCH 118/201] perf metric: Add events for the current list mainline inclusion from mainline-v5.9-rc1 commit fc393839c11bbe2c7f1a44ab34e5f2a219d8366e category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc393839c11bbe2c7f1a44ab34e5f2a219d8366e ---------------------------------------------------------------------- There's no need to iterate the whole list of groups, when adding new events. The currently created groups are the ones we want to add. Signed-off-by: Jiri Olsa Reviewed-by: Kajol Jain Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: John Garry Cc: Michael Petlan Cc: Namhyung Kim Cc: Paul Clarke Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20200719181320.785305-13-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: hongrongxuan --- tools/perf/util/metricgroup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index ef3f1d41f7db..4a3a24fab67e 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -834,6 +834,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, { struct pmu_event *pe; struct egroup *eg; + LIST_HEAD(list); int i, ret; bool has_match = false; @@ -841,7 +842,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, has_match = true; eg = NULL; - ret = add_metric(group_list, pe, metric_no_group, &eg); + ret = add_metric(&list, pe, metric_no_group, &eg); if (ret) return ret; @@ -850,7 +851,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, * included in the expression. */ ret = resolve_metric(metric_no_group, - group_list, map); + &list, map); if (ret) return ret; } @@ -859,7 +860,7 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, if (!has_match) return -EINVAL; - list_for_each_entry(eg, group_list, nd) { + list_for_each_entry(eg, &list, nd) { if (events->len > 0) strbuf_addf(events, ","); @@ -871,6 +872,8 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group, &eg->pctx); } } + + list_splice(&list, group_list); return 0; } -- 2.27.0