lkml.org 
[lkml]   [2019]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 4/4] perf stat: Fix metrics with --no-merge
Date
From: Andi Kleen <ak@linux.intel.com>

Since 8c5421c016a4 ("perf pmu: Display pmu name when printing ...")
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.

Fixes: 8c5421c016a4 ("perf pmu: Display pmu name when printing ...")
Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
Signed-off-by: Andi Kleen <ak@linux.intel.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,
--
2.20.1
\
 
 \ /
  Last update: 2019-06-24 21:37    [W:0.102 / U:1.856 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site