public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Changbin Du <changbin.du@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: Re: [RESEND PATCH v2] perf stat: improve readability of shadow stats
Date: Fri, 19 Mar 2021 11:00:29 +0100	[thread overview]
Message-ID: <YFR2PbJ+zRLunsR1@krava> (raw)
In-Reply-To: <20210318151240.ms4ic6xfa4xx7t2u@mail.google.com>

On Thu, Mar 18, 2021 at 11:12:40PM +0800, Changbin Du wrote:
> On Tue, Mar 16, 2021 at 02:53:41PM +0100, Jiri Olsa wrote:
> > On Mon, Mar 15, 2021 at 10:30:47PM +0800, Changbin Du wrote:
> > 
> > SNIP
> > 
> > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> > > index 6ccf21a72f06..3f800e71126f 100644
> > > --- a/tools/perf/util/stat-shadow.c
> > > +++ b/tools/perf/util/stat-shadow.c
> > > @@ -9,6 +9,7 @@
> > >  #include "expr.h"
> > >  #include "metricgroup.h"
> > >  #include "cgroup.h"
> > > +#include "units.h"
> > >  #include <linux/zalloc.h>
> > >  
> > >  /*
> > > @@ -1270,18 +1271,15 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> > >  		generic_metric(config, evsel->metric_expr, evsel->metric_events, NULL,
> > >  				evsel->name, evsel->metric_name, NULL, 1, cpu, out, st);
> > >  	} else if (runtime_stat_n(st, STAT_NSECS, cpu, &rsd) != 0) {
> > > -		char unit = 'M';
> > > -		char unit_buf[10];
> > > +		char unit = ' ';
> > > +		char unit_buf[10] = "/sec";
> > >  
> > >  		total = runtime_stat_avg(st, STAT_NSECS, cpu, &rsd);
> > > -
> > >  		if (total)
> > > -			ratio = 1000.0 * avg / total;
> > > -		if (ratio < 0.001) {
> > > -			ratio *= 1000;
> > > -			unit = 'K';
> > > -		}
> > > -		snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit);
> > > +			ratio = convert_unit_double(1000000000.0 * avg / total, &unit);
> > > +
> > > +		if (unit != ' ')
> > > +			snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit);
> > >  		print_metric(config, ctxp, NULL, "%8.3f", unit_buf, ratio);
> > 
> > hum, does this still change the metric unit in the csv output? 'perf -a -x,'
> >
> The unit is changed in csv format, too. See below.
> 
> before:
> $ sudo ./perf stat -a -x, -- sleep 1
> 8037.85,msec,cpu-clock,8037851596,100.00,7.999,CPUs utilized
> 714,,context-switches,8037838466,100.00,0.089,K/sec
> 11,,cpu-migrations,8037832590,100.00,0.001,K/sec
> 71,,page-faults,8037824974,100.00,0.009,K/sec
> 84033551,,cycles,8037750471,100.00,0.010,GHz
> 22563553,,instructions,8037733879,100.00,0.27,insn per cycle
> 4685736,,branches,8037708301,100.00,0.583,M/sec
> 356327,,branch-misses,8037667950,100.00,7.60,of all branches
> 
> after:
> $ sudo ./perf stat -a -x, -- sleep 1
> 8026.19,msec,cpu-clock,8026194365,100.00,7.983,CPUs utilized
> 621,,context-switches,8026178186,100.00,77.372,/sec
> 16,,cpu-migrations,8026172135,100.00,1.993,/sec
> 73,,page-faults,8026142626,100.00,9.095,/sec
> 92645028,,cycles,8026066285,100.00,0.012,GHz
> 56268285,,instructions,8026048894,100.00,0.61,insn per cycle
> 10979859,,branches,8026022127,100.00,1.368,M/sec
> 441719,,branch-misses,8025981169,100.00,4.02,of all branches
> 
> But is this a real problem?

perhaps not, Andi, any idea about this?

thanks,
jirka


  reply	other threads:[~2021-03-19 10:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 14:30 [RESEND PATCH v2] perf stat: improve readability of shadow stats Changbin Du
2021-03-16 13:53 ` Jiri Olsa
2021-03-18 15:12   ` Changbin Du
2021-03-19 10:00     ` Jiri Olsa [this message]
2021-03-22  3:02       ` Andi Kleen
2021-03-19  1:01 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YFR2PbJ+zRLunsR1@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=changbin.du@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox