linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] intel-speed-select: Fix json perf-profile output output
@ 2020-05-11 19:06 Prarit Bhargava
  2020-05-15 19:58 ` Srinivas Pandruvada
  0 siblings, 1 reply; 2+ messages in thread
From: Prarit Bhargava @ 2020-05-11 19:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Prarit Bhargava, Srinivas Pandruvada, platform-driver-x86

The 'intel-speed-select -f json perf-profile get-lock-status' command
outputs the package, die, and cpu data as separate fields.

ex)

  "package-0": {
    "die-0": {
      "cpu-0": {

Commit 74062363f855 ("tools/power/x86/intel-speed-select: Avoid duplicate Package strings for json") prettied this output so that it is a single line for
some json output commands and the same should be done for other commands.

Output package, die, and cpu info in a single line when using json output.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org
---
 .../x86/intel-speed-select/isst-display.c     | 26 +++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c
index f6e2ce181123..e105fece47b6 100644
--- a/tools/power/x86/intel-speed-select/isst-display.c
+++ b/tools/power/x86/intel-speed-select/isst-display.c
@@ -316,21 +316,31 @@ void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
 {
 	char header[256];
 	char value[256];
+	int level = 1;
+
+	if (out_format_is_json()) {
+		snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
+			 get_physical_package_id(cpu), get_physical_die_id(cpu),
+			 cpu);
+		format_and_print(outf, level++, header, NULL);
+	} else {
+		snprintf(header, sizeof(header), "package-%d",
+			 get_physical_package_id(cpu));
+		format_and_print(outf, level++, header, NULL);
+		snprintf(header, sizeof(header), "die-%d",
+			 get_physical_die_id(cpu));
+		format_and_print(outf, level++, header, NULL);
+		snprintf(header, sizeof(header), "cpu-%d", cpu);
+		format_and_print(outf, level++, header, NULL);
+	}
 
-	snprintf(header, sizeof(header), "package-%d",
-		 get_physical_package_id(cpu));
-	format_and_print(outf, 1, header, NULL);
-	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
-	format_and_print(outf, 2, header, NULL);
-	snprintf(header, sizeof(header), "cpu-%d", cpu);
-	format_and_print(outf, 3, header, NULL);
 	if (str0 && !val)
 		snprintf(value, sizeof(value), "%s", str0);
 	else if (str1 && val)
 		snprintf(value, sizeof(value), "%s", str1);
 	else
 		snprintf(value, sizeof(value), "%u", val);
-	format_and_print(outf, 4, prefix, value);
+	format_and_print(outf, level, prefix, value);
 
 	format_and_print(outf, 1, NULL, NULL);
 }
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] intel-speed-select: Fix json perf-profile output output
  2020-05-11 19:06 [PATCH] intel-speed-select: Fix json perf-profile output output Prarit Bhargava
@ 2020-05-15 19:58 ` Srinivas Pandruvada
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Pandruvada @ 2020-05-15 19:58 UTC (permalink / raw)
  To: Prarit Bhargava, linux-kernel; +Cc: platform-driver-x86

On Mon, 2020-05-11 at 15:06 -0400, Prarit Bhargava wrote:

I prefer prefix as: "tools/power/x86/intel-speed-select" instead of
just "intel-speed-select". 

Fixed and applied.

Thanks,
Srinivas

> The 'intel-speed-select -f json perf-profile get-lock-status' command
> outputs the package, die, and cpu data as separate fields.
> 
> ex)
> 
>   "package-0": {
>     "die-0": {
>       "cpu-0": {
> 
> Commit 74062363f855 ("tools/power/x86/intel-speed-select: Avoid
> duplicate Package strings for json") prettied this output so that it
> is a single line for
> some json output commands and the same should be done for other
> commands.
> 
> Output package, die, and cpu info in a single line when using json
> output.
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: platform-driver-x86@vger.kernel.org
> ---
>  .../x86/intel-speed-select/isst-display.c     | 26 +++++++++++++--
> ----
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/power/x86/intel-speed-select/isst-display.c
> b/tools/power/x86/intel-speed-select/isst-display.c
> index f6e2ce181123..e105fece47b6 100644
> --- a/tools/power/x86/intel-speed-select/isst-display.c
> +++ b/tools/power/x86/intel-speed-select/isst-display.c
> @@ -316,21 +316,31 @@ void isst_ctdp_display_core_info(int cpu, FILE
> *outf, char *prefix,
>  {
>  	char header[256];
>  	char value[256];
> +	int level = 1;
> +
> +	if (out_format_is_json()) {
> +		snprintf(header, sizeof(header), "package-%d:die-
> %d:cpu-%d",
> +			 get_physical_package_id(cpu),
> get_physical_die_id(cpu),
> +			 cpu);
> +		format_and_print(outf, level++, header, NULL);
> +	} else {
> +		snprintf(header, sizeof(header), "package-%d",
> +			 get_physical_package_id(cpu));
> +		format_and_print(outf, level++, header, NULL);
> +		snprintf(header, sizeof(header), "die-%d",
> +			 get_physical_die_id(cpu));
> +		format_and_print(outf, level++, header, NULL);
> +		snprintf(header, sizeof(header), "cpu-%d", cpu);
> +		format_and_print(outf, level++, header, NULL);
> +	}
>  
> -	snprintf(header, sizeof(header), "package-%d",
> -		 get_physical_package_id(cpu));
> -	format_and_print(outf, 1, header, NULL);
> -	snprintf(header, sizeof(header), "die-%d",
> get_physical_die_id(cpu));
> -	format_and_print(outf, 2, header, NULL);
> -	snprintf(header, sizeof(header), "cpu-%d", cpu);
> -	format_and_print(outf, 3, header, NULL);
>  	if (str0 && !val)
>  		snprintf(value, sizeof(value), "%s", str0);
>  	else if (str1 && val)
>  		snprintf(value, sizeof(value), "%s", str1);
>  	else
>  		snprintf(value, sizeof(value), "%u", val);
> -	format_and_print(outf, 4, prefix, value);
> +	format_and_print(outf, level, prefix, value);
>  
>  	format_and_print(outf, 1, NULL, NULL);
>  }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-15 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 19:06 [PATCH] intel-speed-select: Fix json perf-profile output output Prarit Bhargava
2020-05-15 19:58 ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).