提交 411bc316 编写于 作者: A Andi Kleen 提交者: Arnaldo Carvalho de Melo

perf stat: Fix adding multiple event groups

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: NAndi Kleen <ak@linux.intel.com>
Acked-by: NJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170914205735.18431-1-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 c896f85a
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册