Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9934060ybi; Wed, 24 Jul 2019 12:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhKyE7Q9Wqc8FUFXHAIyy8nr15s6fjMDgT6FT76glw/enHOBnzAAS2s3m9tsfNDprfJNzp X-Received: by 2002:a17:902:788f:: with SMTP id q15mr88854262pll.236.1563996951262; Wed, 24 Jul 2019 12:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996951; cv=none; d=google.com; s=arc-20160816; b=zPfBGHHi9wNCz09hT5CSuM0hqRKvYLRPRftmF5kRig3yiiTKTLiX1istuvcWXSvNXd o3ChOY/FiFJrmIpDWOSlUlsaGQNTPyR1f7Ghgu+dzaNWFY5padhHGQAMEhCRYMA51FYO jmSIYN7m0u0mLjOEY5V3j/+cV8mYgOCRwXEsVP2hN/k8rvH94WrNpglykA6YehTBXKxF nYbEicMV1+wCtpsToQIqkbZ+OnwS4uMifBOkTbohpZbA+JHx+y/4f976mDjMN9nHauKv CpNMUuZJzJKlsYAXTQYyWHTuTKtpeg/gbMSJDI6w2PIsSMDirB6Yxmx/OOFElD+JnFIq DTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wg/L2O1gyTFKHRDvRX7oC3ekcNjLIVzKRj3cg+Db8D8=; b=Stm+V3D6P/MuK/SiXVPfhkwQJQtf9buTToHT7hacG10e1+aa+zOuQlyI3Lwrij6cq/ D28LlXXkSpJNBzVwae1Ffid8ES+4+1pbtplzbi2KPTeRAJiuqBSzhAI3YLu5lceN6PxJ vcrbIiDrTAo7Xqk4ADkyvLviU+B+shlez81535AmRDhEEftCbj/KDVzdmPWVlnJfVCVh muEz6vtJG4oLYY6HO2o09FgxdHUuaqp1hde+9X9UbVxufGFqmZ6JEFtoIwcqsKctjvL1 2XPWD6MGUvCf38LqRzkC1VhgNHqecBnPwDZfdhdY8WRVzFsVYWY+Z8jHzmVsogWefdja LJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sRjcgZRn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si18166661pff.220.2019.07.24.12.35.37; Wed, 24 Jul 2019 12:35:51 -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=@kernel.org header.s=default header.b=sRjcgZRn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388759AbfGXTem (ORCPT + 99 others); Wed, 24 Jul 2019 15:34:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:57210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388757AbfGXTej (ORCPT ); Wed, 24 Jul 2019 15:34:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4695122ADB; Wed, 24 Jul 2019 19:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996878; bh=37qhZRHmYZ4Vv5ccEyMlz+I5hVSPh0cUKDBsnMTKIrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sRjcgZRnqVq+QiRqV+cnYqF6Cr51XE+x3a65UVr5wDZC8RkSD1/+S1M9w+/8rN4Nq ivRqzL/o+O4KOAbWaUnMR9/Z0IBMEAYAuu/iB+HEx7eExsNp1d2Z336dc2ugMWFsOO Nbf81m33PpJRmrx9Gf8uSsanpMxfxaioyR3UyDes= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Jiri Olsa , Agustin Vega-Frias , Kan Liang , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.2 211/413] perf stat: Fix metrics with --no-merge Date: Wed, 24 Jul 2019 21:18:22 +0200 Message-Id: <20190724191749.604511941@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e3a9427323a53ceee540276a74af7706f350d052 ] 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 Signed-off-by: Sasha Levin --- 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 e545e2a8ae71..0ef98e991ade 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -723,6 +723,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); @@ -742,7 +743,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; @@ -759,6 +772,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