From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] perf, tools: Fix adding multiple event groups
Date: Thu, 14 Sep 2017 13:57:35 -0700 [thread overview]
Message-ID: <20170914205735.18431-1-andi@firstfloor.org> (raw)
From: Andi Kleen <ak@linux.intel.com>
The -M metric group parser threw away the events of earlier
groups when multiple groups were specified. Fix this here
by not overwriting the string incorrectly.
Now this works correctly:
% perf stat -M Summary,SMT --metric-only -a sleep 1
Performance counter stats for 'system wide':
Instructions CPI CLKS CPU_Utilization GFLOPs SMT_2T_Utilization SMT_2T_Utilization Kernel_Utilization CoreIPC CORE_CLKS
900907376.0 2.7 2398954144.0 0.1 0.0 0.2 0.2 0.1 0.4 2080822855.5
while previously it would only show the SMT metrics.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/util/metricgroup.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 0794f02cbb8f..ce18474adc12 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -373,9 +373,6 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events,
int ret = -EINVAL;
int i, j;
- strbuf_init(events, 100);
- strbuf_addf(events, "%s", "");
-
if (!map)
return 0;
@@ -433,6 +430,10 @@ static int metricgroup__add_metric_list(const char *list, struct strbuf *events,
if (!nlist)
return -ENOMEM;
llist = nlist;
+
+ strbuf_init(events, 100);
+ strbuf_addf(events, "%s", "");
+
while ((p = strsep(&llist, ",")) != NULL) {
ret = metricgroup__add_metric(p, events, group_list);
if (ret == -EINVAL) {
--
2.9.5
next reply other threads:[~2017-09-14 20:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-14 20:57 Andi Kleen [this message]
2017-09-18 6:58 ` [PATCH] perf, tools: Fix adding multiple event groups Jiri Olsa
2017-09-22 16:44 ` [tip:perf/core] perf stat: " tip-bot for Andi Kleen
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=20170914205735.18431-1-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.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