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] [day] [month] [year] [list]
Message-ID: <aDdQyPNrnd4b-qWg@x1>
Date: Wed, 28 May 2025 15:07:04 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Suchit Karunakaran <suchitkarunakaran@...il.com>
Cc: Yicong Yang <yangyicong@...ilicon.com>,
	Jonathan Cameron <jonathan.cameron@...wei.com>,
	Junhao He <hejunhao3@...wei.com>,
	Mark Rutland <mark.rutland@....com>,
	Peter Zijlstra <peterz@...radead.org>,
	Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>,
	Ingo Molnar <mingo@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
	alexander.shishkin@...ux.intel.com,
	linux-perf-users@...r.kernel.org,
	linux-kernel-mentees@...ts.linux.dev, linux-kernel@...r.kernel.org,
	skhan@...uxfoundation.org
Subject: Re: [PATCH RESEND] perf stat: Fix JSON output formatting in
 iostat_prefix()

On Tue, May 20, 2025 at 03:15:25PM +0530, Suchit Karunakaran wrote:
> The iostat_prefix() function previously included a TODO noting that its output
> format was incorrect in JSON mode. This patch corrects that by conditionally
> formatting the prefix string based on the output mode specified in
> perf_stat_config.

O don't have how to test this as I dont have:

access("/sys/bus/event_source/devices/uncore_iio_0", F_OK) = -1 ENOENT (No such file or directory)
write(2, ""..., 37Unsupported uncore pmu configuration
)                     = 37
write(2, ""..., 43
 Usage: perf stat [<options>] [<command>]
)                     = 43
write(2, ""..., 1
<SNIP>
write(2, ""..., 84                          measure I/O performance metrics provided by arch/platform
)                     = 84
exit_group(129)                         = ?
+++ exited with 129 +++
root@x1:~# strace -s0 perf stat --iostat --timeout 1000

Could someone with access to hardware with this capability to try this
patch and provide a  Tested-by?

- Arnaldo
 
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@...il.com>
> ---
>  tools/perf/arch/x86/util/iostat.c | 35 ++++++++++++++++++++-----------
>  1 file changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c
> index 7442a2cd87ed..1d9c20dab5c7 100644
> --- a/tools/perf/arch/x86/util/iostat.c
> +++ b/tools/perf/arch/x86/util/iostat.c
> @@ -403,18 +403,29 @@ void iostat_prefix(struct evlist *evlist,
>  	struct iio_root_port *rp = evlist->selected->priv;
>  
>  	if (rp) {
> -		/*
> -		 * TODO: This is the incorrect format in JSON mode.
> -		 *       See prepare_timestamp()
> -		 */
> -		if (ts)
> -			sprintf(prefix, "%6lu.%09lu%s%04x:%02x%s",
> -				ts->tv_sec, ts->tv_nsec,
> -				config->csv_sep, rp->domain, rp->bus,
> -				config->csv_sep);
> -		else
> -			sprintf(prefix, "%04x:%02x%s", rp->domain, rp->bus,
> -				config->csv_sep);
> +		if (ts) {
> +			if (config->json_output)
> +				sprintf(prefix,
> +					"\"interval\" : %lu.%09lu, \"device\" : \"%04x:%02x\"",
> +					(unsigned long)ts->tv_sec, ts->tv_nsec,
> +					rp->domain, rp->bus);
> +			else if (config->csv_output)
> +				sprintf(prefix, "%lu.%09lu%s%04x:%02x%s",
> +					(unsigned long)ts->tv_sec, ts->tv_nsec,
> +					config->csv_sep,
> +					rp->domain, rp->bus, config->csv_sep);
> +			else
> +				sprintf(prefix, "%6lu.%09lu %04x:%02x%s",
> +					(unsigned long)ts->tv_sec, ts->tv_nsec,
> +					rp->domain, rp->bus, config->csv_sep);
> +		} else {
> +			if (config->json_output)
> +				sprintf(prefix, "\"device\" : \"%04x:%02x\"",
> +					rp->domain, rp->bus);
> +			else
> +				sprintf(prefix, "%04x:%02x%s", rp->domain,
> +					rp->bus, config->csv_sep);
> +		}
>  	}
>  }
>  
> -- 
> 2.49.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ