Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4577292ybb; Tue, 14 Apr 2020 09:58:10 -0700 (PDT) X-Google-Smtp-Source: APiQypLZvFXT8dSVttUYHnzZpccsUduhKmgqi1fXbT5tw5wisDuIDmiWGcxIYmyVoKAo5FjsSHko X-Received: by 2002:a17:906:b28f:: with SMTP id q15mr1049485ejz.188.1586883490325; Tue, 14 Apr 2020 09:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586883490; cv=none; d=google.com; s=arc-20160816; b=uLvLPHfE9G/VFvusmrMEWDsumb4Nhn8OiTGObLxLTY5U75Vg6wqdqpxzpy2639ubT/ Qr576j+vgzIL5NU8E0x1IscG1WLTiKneYDnU3IKbvIApNaERd8v+4GpNbGEVxCRZelRT S4bZXEiaZdjTB2MNwB2s5IOvzkUXzV1RVCY/8+rx2WmdCapIZcNn2B3odnwFHPJZi/MZ 0D+df2KLLXmoFF3sIDPpUtaBV/jXDvku0FZZTd0Wh16V/cElk1PDmSnr5Kb3gnkWLRlA S6U+tBMnnQhhLhyQkdeahBRX92lltsg4BX0lxx6/A8sVK66/iNM3QmrQjhi/cjQJUm86 up9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VCy7D3AuStHm/U9mKaoABbvW3AYc6Zwfkl2SZVLtrcM=; b=EmaNsJGr8uL7zf5k2G5YLbGyaOuKoprTJy5u52Nm35JRTWQjk39yePnkQCvXrOXRYP Uc/NhvU9sTQEiDjq9aRIrxnxHxO2dINuux/uSSda1FmmmGUiM5yQTqrypZNPzgKJcnGS L+xjB2b4DeXLN/ZrTuTqxcpX1KLqo581oS7fhTI0gQuDIWkjfB5/zLIm+rdUkSVnIpBs 32Vqug8/5ilhWyc0XOQ3HTVr9bcj9U02LbslkeO1SBYoVI3BpbLSw/Pbe6Rc4k6i1WAp gEkELugR+4SdyrCMEd14X8hxEpPqfwdPoPDmXG1NXK4SSInqpdvm+jtX1H/XPWdqUrGH KPlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OrlZkcWa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb28si8642582edb.11.2020.04.14.09.57.45; Tue, 14 Apr 2020 09:58:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OrlZkcWa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440515AbgDNQvg (ORCPT + 99 others); Tue, 14 Apr 2020 12:51:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:55616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440391AbgDNQtU (ORCPT ); Tue, 14 Apr 2020 12:49:20 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 567D22076C; Tue, 14 Apr 2020 16:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586882950; bh=kjNU8gkJH0MuwVzru11aJkVZj5ZBZx/fNWrBzMDaFgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrlZkcWaTwuSoDJ5Sr0lNxMuyaLW87+joKMjI4013YrfOPVX66DkOznAp6eI+dCFo P+vL/+GkMkVw2BUyYT/CITXiZtvsSU42KATNahDIbqh+qj6XiL3p62m5IiEeIAfSEb AyTDMFhz45k/YelbeCOLntOoZhoCIfm8fU4xfAWA= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jin Yao , Alexander Shishkin , Andi Kleen , Kan Liang , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 03/15] perf stat: Fix no metric header if --per-socket and --metric-only set Date: Tue, 14 Apr 2020 13:48:42 -0300 Message-Id: <20200414164854.26026-4-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200414164854.26026-1-acme@kernel.org> References: <20200414164854.26026-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jin Yao We received a report that was no metric header displayed if --per-socket and --metric-only were both set. It's hard for script to parse the perf-stat output. This patch fixes this issue. Before: root@kbl-ppc:~# perf stat -a -M CPI --metric-only --per-socket ^C Performance counter stats for 'system wide': S0 8 2.6 2.215270071 seconds time elapsed root@kbl-ppc:~# perf stat -a -M CPI --metric-only --per-socket -I1000 # time socket cpus 1.000411692 S0 8 2.2 2.001547952 S0 8 3.4 3.002446511 S0 8 3.4 4.003346157 S0 8 4.0 5.004245736 S0 8 0.3 After: root@kbl-ppc:~# perf stat -a -M CPI --metric-only --per-socket ^C Performance counter stats for 'system wide': CPI S0 8 2.1 1.813579830 seconds time elapsed root@kbl-ppc:~# perf stat -a -M CPI --metric-only --per-socket -I1000 # time socket cpus CPI 1.000415122 S0 8 3.2 2.001630051 S0 8 2.9 3.002612278 S0 8 4.3 4.003523594 S0 8 3.0 5.004504256 S0 8 3.7 Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20200331180226.25915-1-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat-shadow.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 0fd713d3674f..03ecb8cd0eec 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -803,8 +803,11 @@ static void generic_metric(struct perf_stat_config *config, out->force_header ? (metric_name ? metric_name : name) : "", 0); } - } else - print_metric(config, ctxp, NULL, NULL, "", 0); + } else { + print_metric(config, ctxp, NULL, NULL, + out->force_header ? + (metric_name ? metric_name : name) : "", 0); + } for (i = 1; i < pctx.num_ids; i++) zfree(&pctx.ids[i].name); -- 2.21.1