From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Michael Petlan <mpetlan@redhat.com>,
Joe Mario <jmario@redhat.com>, Andi Kleen <ak@linux.intel.com>,
Kajol Jain <kjain@linux.ibm.com>
Subject: [PATCH 2/3] perf tools: Factor metric setup code into metricgroup__setup function
Date: Wed, 11 Dec 2019 23:47:59 +0100 [thread overview]
Message-ID: <20191211224800.9066-3-jolsa@kernel.org> (raw)
In-Reply-To: <20191211224800.9066-1-jolsa@kernel.org>
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@kernel.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
next prev parent reply other threads:[~2019-12-11 22:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 22:47 [RFC 0/3] perf tools: Add support for used defined metric Jiri Olsa
2019-12-11 22:47 ` [PATCH 1/3] perf tools: Factor metric addition into add_metric function Jiri Olsa
2019-12-11 22:47 ` Jiri Olsa [this message]
2019-12-11 22:48 ` [PATCH 3/3] perf stat: Add --metric option Jiri Olsa
2019-12-11 23:02 ` Andi Kleen
2019-12-12 9:41 ` Jiri Olsa
2019-12-11 23:01 ` [RFC 0/3] perf tools: Add support for used defined metric Andi Kleen
2019-12-12 9:37 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191211224800.9066-3-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jmario@redhat.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox