From 28ba4a7842588c0d3daf91b8e910d04f72f20c26 Mon Sep 17 00:00:00 2001
From: Jiri Olsa <jolsa@kernel.org>
Date: Tue, 9 Jun 2020 12:50:42 -0300
Subject: [PATCH 097/201] perf tools: Add fake_pmu to parse_group() function

mainline inclusion
from mainline-v5.9-rc1
commit 68173bda6ac9d498e450276323f1c10a1d0307ad
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=68173bda6ac9d498e450276323f1c10a1d0307ad

----------------------------------------------------------------------

Allow to pass fake_pmu in parse_groups function so it can be used in
parse_events call.

It's will be passed by the upcoming metricgroup__parse_groups_test
function.

Committer notes:

Made it a 'struct perf_pmu' pointer, in line with the changes at the
start of this patchkit to avoid statics deep down in library code.

Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200602214741.1218986-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
---
 tools/perf/util/metricgroup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index d2f54aa12b33..9fa47eb1b968 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -719,6 +719,7 @@ static void metricgroup__free_egroups(struct list_head *group_list)
 static int parse_groups(struct perf_evlist *perf_evlist, const char *str,
 			bool metric_no_group,
 			bool metric_no_merge,
+			struct perf_pmu *fake_pmu,
 			struct rblist *metric_events)
 {
 	struct parse_events_error parse_error;
@@ -734,7 +735,7 @@ static int parse_groups(struct perf_evlist *perf_evlist, const char *str,
 		return ret;
 	pr_debug("adding %s\n", extra_events.buf);
 	memset(&parse_error, 0, sizeof(struct parse_events_error));
-	ret = parse_events(perf_evlist, extra_events.buf, &parse_error);
+	ret = __parse_events(perf_evlist, extra_events.buf, &parse_error, fake_pmu);
 	if (ret) {
 		parse_events_print_error(&parse_error, extra_events.buf);
 		goto out;
@@ -756,7 +757,7 @@ int metricgroup__parse_groups(const struct option *opt,
 	struct perf_evlist *perf_evlist = *(struct perf_evlist **)opt->value;
 
 	return parse_groups(perf_evlist, str, metric_no_group,
-			    metric_no_merge, metric_events);
+			    metric_no_merge, NULL, metric_events);
 }
 
 bool metricgroup__has_metric(const char *metric)
-- 
2.27.0

