From: tip-bot for Andi Kleen <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, agustinv@codeaurora.org, mingo@kernel.org,
ak@linux.intel.com, acme@redhat.com,
linux-kernel@vger.kernel.org, tglx@linutronix.de,
kan.liang@linux.intel.com, hpa@zytor.com
Subject: [tip:perf/core] perf stat: Fix metrics with --no-merge
Date: Wed, 3 Jul 2019 07:29:57 -0700 [thread overview]
Message-ID: <tip-e3a9427323a53ceee540276a74af7706f350d052@git.kernel.org> (raw)
In-Reply-To: <20190624193711.35241-5-andi@firstfloor.org>
Commit-ID: e3a9427323a53ceee540276a74af7706f350d052
Gitweb: https://git.kernel.org/tip/e3a9427323a53ceee540276a74af7706f350d052
Author: Andi Kleen <ak@linux.intel.com>
AuthorDate: Mon, 24 Jun 2019 12:37:11 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 1 Jul 2019 22:50:41 -0300
perf stat: Fix metrics with --no-merge
Since Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing
unmerged events in stat") using --no-merge adds the PMU name to the
evsel name.
This breaks the metric value lookup because the parser doesn't know
about this.
Remove the extra postfixes for the metric evaluation.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing unmerged events in stat")
Link: http://lkml.kernel.org/r/20190624193711.35241-5-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/stat-shadow.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 3f8fd127d31e..cb891e5c2969 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -724,6 +724,7 @@ static void generic_metric(struct perf_stat_config *config,
double ratio;
int i;
void *ctxp = out->ctx;
+ char *n, *pn;
expr__ctx_init(&pctx);
expr__add_id(&pctx, name, avg);
@@ -743,7 +744,19 @@ static void generic_metric(struct perf_stat_config *config,
stats = &v->stats;
scale = 1.0;
}
- expr__add_id(&pctx, metric_events[i]->name, avg_stats(stats)*scale);
+
+ n = strdup(metric_events[i]->name);
+ if (!n)
+ return;
+ /*
+ * This display code with --no-merge adds [cpu] postfixes.
+ * These are not supported by the parser. Remove everything
+ * after the space.
+ */
+ pn = strchr(n, ' ');
+ if (pn)
+ *pn = 0;
+ expr__add_id(&pctx, n, avg_stats(stats)*scale);
}
if (!metric_events[i]) {
const char *p = metric_expr;
@@ -760,6 +773,9 @@ static void generic_metric(struct perf_stat_config *config,
(metric_name ? metric_name : name) : "", 0);
} else
print_metric(config, ctxp, NULL, NULL, "", 0);
+
+ for (i = 1; i < pctx.num_ids; i++)
+ free((void *)pctx.ids[i].name);
}
void perf_stat__print_shadow_stats(struct perf_stat_config *config,
next prev parent reply other threads:[~2019-07-03 14:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 19:37 Some bug fixes for perf stat metrics Andi Kleen
2019-06-24 19:37 ` [PATCH v1 1/4] perf stat: Make metric event lookup more robust Andi Kleen
2019-07-03 14:27 ` [tip:perf/core] " tip-bot for Andi Kleen
2019-06-24 19:37 ` [PATCH v1 2/4] perf stat: Don't merge events in the same PMU Andi Kleen
2019-07-03 14:28 ` [tip:perf/core] " tip-bot for Andi Kleen
2019-06-24 19:37 ` [PATCH v1 3/4] perf stat: Fix group lookup for metric group Andi Kleen
2019-07-03 14:29 ` [tip:perf/core] " tip-bot for Andi Kleen
2019-06-24 19:37 ` [PATCH v1 4/4] perf stat: Fix metrics with --no-merge Andi Kleen
2019-07-03 14:29 ` tip-bot for Andi Kleen [this message]
2019-06-25 9:23 ` Some bug fixes for perf stat metrics Jiri Olsa
2019-06-26 18:43 ` Arnaldo Carvalho de Melo
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=tip-e3a9427323a53ceee540276a74af7706f350d052@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=agustinv@codeaurora.org \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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