lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191211224800.9066-3-jolsa@kernel.org>
Date:   Wed, 11 Dec 2019 23:47:59 +0100
From:   Jiri Olsa <jolsa@...nel.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Michael Petlan <mpetlan@...hat.com>,
        Joe Mario <jmario@...hat.com>, Andi Kleen <ak@...ux.intel.com>,
        Kajol Jain <kjain@...ux.ibm.com>
Subject: [PATCH 2/3] perf tools: Factor metric setup code into metricgroup__setup function

Factoring metric setup code into metricgroup__setup function,
so it can be used to add metric from different sources in
following patches.

Link: https://lkml.kernel.org/n/tip-7hjix4t30ls3qqd4l60dbr2n@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 tools/perf/util/metricgroup.c | 38 +++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 1d01958c148d..abcfa3c1b4d5 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -521,32 +521,44 @@ static void metricgroup__free_egroups(struct list_head *group_list)
 	}
 }
 
+static int metricgroup__setup(struct evlist *evlist,
+			      struct rblist *metric_events,
+			      struct strbuf *extra_events,
+			      struct list_head *group_list)
+{
+	struct parse_events_error parse_error;
+	int ret;
+
+	pr_debug("adding %s\n", extra_events->buf);
+	bzero(&parse_error, sizeof(parse_error));
+
+	ret = parse_events(evlist, extra_events->buf, &parse_error);
+	if (ret) {
+		parse_events_print_error(&parse_error, extra_events->buf);
+		return ret;
+	}
+
+	if (metric_events->nr_entries == 0)
+		metricgroup__rblist_init(metric_events);
+	return metricgroup__setup_events(group_list, evlist, metric_events);
+}
+
 int metricgroup__parse_groups(const struct option *opt,
 			   const char *str,
 			   struct rblist *metric_events)
 {
-	struct parse_events_error parse_error;
 	struct evlist *perf_evlist = *(struct evlist **)opt->value;
 	struct strbuf extra_events;
 	LIST_HEAD(group_list);
 	int ret;
 
-	if (metric_events->nr_entries == 0)
-		metricgroup__rblist_init(metric_events);
 	ret = metricgroup__add_metric_list(str, &extra_events, &group_list);
 	if (ret)
 		return ret;
-	pr_debug("adding %s\n", extra_events.buf);
-	bzero(&parse_error, sizeof(parse_error));
-	ret = parse_events(perf_evlist, extra_events.buf, &parse_error);
-	if (ret) {
-		parse_events_print_error(&parse_error, extra_events.buf);
-		goto out;
-	}
+
+	ret = metricgroup__setup(perf_evlist, metric_events, &extra_events,
+				 &group_list);
 	strbuf_release(&extra_events);
-	ret = metricgroup__setup_events(&group_list, perf_evlist,
-					metric_events);
-out:
 	metricgroup__free_egroups(&group_list);
 	return ret;
 }
-- 
2.21.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ