Skip to content

Commit aa8b650

Browse files
praritspandruvada
authored andcommitted
tools/power/x86/intel-speed-select: Fix json perf-profile output output
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 7406236 ("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 <[email protected]> Cc: Srinivas Pandruvada <[email protected]> Cc: [email protected] Signed-off-by: Srinivas Pandruvada <[email protected]>
1 parent f441d66 commit aa8b650

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tools/power/x86/intel-speed-select/isst-display.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,21 +316,31 @@ void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
316316
{
317317
char header[256];
318318
char value[256];
319+
int level = 1;
320+
321+
if (out_format_is_json()) {
322+
snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
323+
get_physical_package_id(cpu), get_physical_die_id(cpu),
324+
cpu);
325+
format_and_print(outf, level++, header, NULL);
326+
} else {
327+
snprintf(header, sizeof(header), "package-%d",
328+
get_physical_package_id(cpu));
329+
format_and_print(outf, level++, header, NULL);
330+
snprintf(header, sizeof(header), "die-%d",
331+
get_physical_die_id(cpu));
332+
format_and_print(outf, level++, header, NULL);
333+
snprintf(header, sizeof(header), "cpu-%d", cpu);
334+
format_and_print(outf, level++, header, NULL);
335+
}
319336

320-
snprintf(header, sizeof(header), "package-%d",
321-
get_physical_package_id(cpu));
322-
format_and_print(outf, 1, header, NULL);
323-
snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
324-
format_and_print(outf, 2, header, NULL);
325-
snprintf(header, sizeof(header), "cpu-%d", cpu);
326-
format_and_print(outf, 3, header, NULL);
327337
if (str0 && !val)
328338
snprintf(value, sizeof(value), "%s", str0);
329339
else if (str1 && val)
330340
snprintf(value, sizeof(value), "%s", str1);
331341
else
332342
snprintf(value, sizeof(value), "%u", val);
333-
format_and_print(outf, 4, prefix, value);
343+
format_and_print(outf, level, prefix, value);
334344

335345
format_and_print(outf, 1, NULL, NULL);
336346
}

0 commit comments

Comments
 (0)