lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 Mar 2021 14:53:41 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Changbin Du <changbin.du@...il.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH v2] perf stat: improve readability of shadow stats

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,'

jirka

>  	} else if (perf_stat_evsel__is(evsel, SMI_NUM)) {
>  		print_smi_cost(config, cpu, out, st, &rsd);
> diff --git a/tools/perf/util/units.c b/tools/perf/util/units.c
> index a46762aec4c9..32c39cfe209b 100644
> --- a/tools/perf/util/units.c
> +++ b/tools/perf/util/units.c

SNIP

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ