diff mbox series

[3/4] tools/power turbostat: Don't print invalid ucode revision

Message ID 20240112124815.970-4-patryk.wlazlyn@linux.intel.com (mailing list archive)
State Superseded, archived
Delegated to: Len Brown
Headers show
Series turbostat msr, perf controls and aperf/mperf via perf | expand

Commit Message

Patryk Wlazlyn Jan. 12, 2024, 12:48 p.m. UTC
Earlier we printed "microcode 0x0" if we failed to obtain it via MSR.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Reviewed-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Len Brown Jan. 13, 2024, 1:15 a.m. UTC | #1
Applied.

This patch can be found on the latest development turbostat branch, here:

git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat

thanks!
-Len

On Fri, Jan 12, 2024 at 6:49 AM Patryk Wlazlyn
<patryk.wlazlyn@linux.intel.com> wrote:
>
> Earlier we printed "microcode 0x0" if we failed to obtain it via MSR.
>
> Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
> Reviewed-by: Len Brown <len.brown@intel.com>
> ---
>  tools/power/x86/turbostat/turbostat.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> index ba10a10c5144..bf733e7d73b5 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -5710,6 +5710,7 @@ void process_cpuid()
>         unsigned int eax, ebx, ecx, edx;
>         unsigned int fms, family, model, stepping, ecx_flags, edx_flags;
>         unsigned long long ucode_patch = 0;
> +       bool ucode_patch_valid = false;
>
>         eax = ebx = ecx = edx = 0;
>
> @@ -5740,6 +5741,8 @@ void process_cpuid()
>         if (!no_msr) {
>                 if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
>                         warnx("get_msr(UCODE)");
> +               else
> +                       ucode_patch_valid = true;
>         }
>
>         /*
> @@ -5751,9 +5754,12 @@ void process_cpuid()
>         __cpuid(0x80000000, max_extended_level, ebx, ecx, edx);
>
>         if (!quiet) {
> -               fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d) microcode 0x%x\n",
> -                       family, model, stepping, family, model, stepping,
> -                       (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
> +               fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)",
> +                       family, model, stepping, family, model, stepping);
> +               if (ucode_patch_valid)
> +                       fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
> +               fputc('\n', outf);
> +
>                 fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level);
>                 fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s %s\n",
>                         ecx_flags & (1 << 0) ? "SSE3" : "-",
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index ba10a10c5144..bf733e7d73b5 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5710,6 +5710,7 @@  void process_cpuid()
 	unsigned int eax, ebx, ecx, edx;
 	unsigned int fms, family, model, stepping, ecx_flags, edx_flags;
 	unsigned long long ucode_patch = 0;
+	bool ucode_patch_valid = false;
 
 	eax = ebx = ecx = edx = 0;
 
@@ -5740,6 +5741,8 @@  void process_cpuid()
 	if (!no_msr) {
 		if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
 			warnx("get_msr(UCODE)");
+		else
+			ucode_patch_valid = true;
 	}
 
 	/*
@@ -5751,9 +5754,12 @@  void process_cpuid()
 	__cpuid(0x80000000, max_extended_level, ebx, ecx, edx);
 
 	if (!quiet) {
-		fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d) microcode 0x%x\n",
-			family, model, stepping, family, model, stepping,
-			(unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
+		fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)",
+			family, model, stepping, family, model, stepping);
+		if (ucode_patch_valid)
+			fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
+		fputc('\n', outf);
+
 		fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level);
 		fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s %s\n",
 			ecx_flags & (1 << 0) ? "SSE3" : "-",