lkml.org 
[lkml]   [2020]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf stat: Fix no metric header if --per-socket and --metric-only set
On Wed, Apr 01, 2020 at 02:02:26AM +0800, Jin Yao wrote:
> 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 <yao.jin@linux.intel.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
> 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.17.1
>

\
 
 \ /
  Last update: 2020-04-03 11:46    [W:0.050 / U:1.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site