Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp979009ybi; Wed, 3 Jul 2019 07:31:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqybAs6ftU2wR0xx/lSguLsbbZt9SaDEeAtc+ocGmrjWBjm1wqK6MmZZ3UMf6+69VBRxAAvy X-Received: by 2002:a63:4f07:: with SMTP id d7mr36469159pgb.77.1562164303635; Wed, 03 Jul 2019 07:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562164303; cv=none; d=google.com; s=arc-20160816; b=oShFdMIw4YkVYP6ht/bkM5iZBbuyHKRWcDGXSKrnBJQBqX+qKYp4+5TJgrxvDOwIXE T17+8Fsm5dY8JcgLEvjxC1TdOUjGmSSSashWkw1SeCx1vgwECgNLj7O4d0f5M/e9MwgG l/XGNTz/qOODFcGrOgX6YolcoMwiljphqWuzyRrMI0ZJiBY8VnNbd2qFvp8AsDsnypo0 IRBnzGMpmF1rhiDLNinU83XnZPScj4vuWV/EsByVQNtngYgBn9jEh2SAi26MfsoThvgH gI3nae+01G2Rd7C2B3WXtS9zjQPrkmdoeQ1OC7MoQVMbufMZdR2rYF2T/CpBZN9+nrqx H/GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=cwZJ4/7DwY+nlFIjz3BW5YppDgjiKGhNyiNJUZe8TsY=; b=ERnsoUegVJjk8evvbl+tcUsKYZYNR6uugOcD+FBIxex8A8M5ShQpnWJRGnh4Qw1Pf8 s3KM5Ckmf5+h1T2uhtoIx+je7XJAF7VhiGVeoA9uA0GIhRMDhez3H6Vk89ygRBsJXhRH YGc227I/uSf3Rux78BZFVAGlZ0FWh0O0LOCiLm8ILs5R7fcwMK3Qej+jguOYN341QAlv 0smbNpJO9MseTHEomKTwSrG16LNWJvYRhcjOTWu+qFLCRwn8P8YzEg4GtZZHcDvoHABt ywtkt+lDO2E7trpP73XHEf5o8kHBi+AsOPkUCSym2R7ofJTZTzlszd5NTj5aqEewKNCV ++KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=QmyVYrH4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si2083138pjt.9.2019.07.03.07.31.28; Wed, 03 Jul 2019 07:31:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=QmyVYrH4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727204AbfGCOaP (ORCPT + 99 others); Wed, 3 Jul 2019 10:30:15 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36983 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726640AbfGCOaO (ORCPT ); Wed, 3 Jul 2019 10:30:14 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x63ETv4T3327103 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 3 Jul 2019 07:29:57 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x63ETv4T3327103 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1562164198; bh=cwZJ4/7DwY+nlFIjz3BW5YppDgjiKGhNyiNJUZe8TsY=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=QmyVYrH4Okp45VBDK4D1yJScaDpDKVysa2JfKS3Gu5VjXa5Vz9es4xvb3TOpiLA/W /Vr9mut4QLVjpzoPqmhChFADX8eEsnmCPYTeoR31/yktJeyiwvV5SYdjmtoHtpvKvf Wyg3Hn9Z0YUJt1YKbAjADy11y9of2/OPkaiq3kJsX0wsRo4rVggsWFmU1fLxp8UyTk UtQnMBmEu8wyF2wn+fX84HHPKV7idTEa9lGGB5dM/g/P3yUMZU7Yye7EI3TJGRvw0f XeYeNJw0XWLSQ6m4z2W/xURYQ/GUgRGrs5DwXVeSu1nIumqAtwaDK4g4CmjQQu66mD 0j/IP3jHomH8w== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x63ETvE93327100; Wed, 3 Jul 2019 07:29:57 -0700 Date: Wed, 3 Jul 2019 07:29:57 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Andi Kleen Message-ID: 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 Reply-To: acme@redhat.com, ak@linux.intel.com, hpa@zytor.com, kan.liang@linux.intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, mingo@kernel.org, agustinv@codeaurora.org In-Reply-To: <20190624193711.35241-5-andi@firstfloor.org> References: <20190624193711.35241-5-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Fix metrics with --no-merge Git-Commit-ID: e3a9427323a53ceee540276a74af7706f350d052 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e3a9427323a53ceee540276a74af7706f350d052 Gitweb: https://git.kernel.org/tip/e3a9427323a53ceee540276a74af7706f350d052 Author: Andi Kleen AuthorDate: Mon, 24 Jun 2019 12:37:11 -0700 Committer: Arnaldo Carvalho de Melo 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 Acked-by: Jiri Olsa Cc: Agustin Vega-Frias Cc: Kan Liang 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 --- 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,