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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZwW0b8km5DnaOETr@google.com>
Date: Tue, 8 Oct 2024 15:38:39 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	John Garry <john.g.garry@...cle.com>, Will Deacon <will@...nel.org>,
	James Clark <james.clark@...aro.org>,
	Mike Leach <mike.leach@...aro.org>, Leo Yan <leo.yan@...ux.dev>,
	Yicong Yang <yangyicong@...ilicon.com>,
	Weilin Wang <weilin.wang@...el.com>,
	Tim Chen <tim.c.chen@...ux.intel.com>,
	Thomas Richter <tmricht@...ux.ibm.com>,
	Sumanth Korikkar <sumanthk@...ux.ibm.com>,
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 3/8] perf stat: Display "none" for NaN with metric
 only json

On Fri, Oct 04, 2024 at 04:41:15PM -0700, Ian Rogers wrote:
> Return earlier for an empty unit case. If snprintf of the fmt doesn't
> produce digits between vals and ends, as happens with NaN, make the
> value "none" as happens in print_metric_end.

Then it could be "NaN" or is there any other case?  But probably "none"
would be more generic.

Thanks,
Namhyung

> 
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/util/stat-display.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 5402998881c4..e392ee5efb45 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -609,19 +609,22 @@ static void print_metric_only_json(struct perf_stat_config *config __maybe_unuse
>  {
>  	struct outstate *os = ctx;
>  	FILE *out = os->fh;
> -	char buf[64], *vals, *ends;
> +	char buf[64], *ends;
>  	char tbuf[1024];
> +	const char *vals;
>  
>  	if (!valid_only_metric(unit))
>  		return;
>  	unit = fixunit(tbuf, os->evsel, unit);
> +	if (!unit[0])
> +		return;
>  	snprintf(buf, sizeof(buf), fmt ?: "", val);
> -	ends = vals = skip_spaces(buf);
> +	vals = ends = skip_spaces(buf);
>  	while (isdigit(*ends) || *ends == '.')
>  		ends++;
>  	*ends = 0;
> -	if (!unit[0] || !vals[0])
> -		return;
> +	if (!vals[0])
> +		vals = "none";
>  	fprintf(out, "%s\"%s\" : \"%s\"", os->first ? "" : ", ", unit, vals);
>  	os->first = false;
>  }
> -- 
> 2.47.0.rc0.187.ge670bccf7e-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ