Re: [PATCH 2/3] tools/power turbostat: Restore u32 truncation for raw counters

From: Zhang, Rui

Date: Fri Nov 27 2026 - 00:54:39 EST


On Tue, 2026-11-24 at 11:27 +0800, Qinyun Tan wrote:
> The u32 size option truncates raw counter values to 32 bits for
> display.
> However, print_hex_value() now prints the full value even when the
> width
> is 32 bits. For example, 0x000000edc994ba0d is printed as edc994ba0d
> instead of c994ba0d.
>
> The print helper cleanup replaced %08x and the unsigned int cast with
> %08llx. The field width is a minimum, so it does not truncate values
> that need more than eight hexadecimal digits. The cast was needed to
> discard the upper 32 bits.
>
> Restore the cast and %08x for raw counters up to 32 bits wide. Leave
> 64-bit raw values and decimal counter formatting unchanged.
>
> Fixes: 092b76a3253f ("tools/power turbostat: Cleanup print helper
> functions")
> Signed-off-by: Qinyun Tan <qinyuntan@xxxxxxxxxxxxxxxxx>

Acked-by: Zhang Rui <rui.zhang@xxxxxxxxx>

-rui
> ---
>  tools/power/x86/turbostat/turbostat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/power/x86/turbostat/turbostat.c
> b/tools/power/x86/turbostat/turbostat.c
> index 4e7eba8d8752..d0f0b4af6094 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -2906,7 +2906,7 @@ static inline int print_hex_value(int width,
> int *printed, char *delim, unsigned
>   char *sep = (*printed)++ ? delim : "";
>  
>   if (width <= 32)
> - return sprintf(outp, "%s%08llx", sep, value);
> + return sprintf(outp, "%s%08x", sep, (unsigned
> int)value);
>   else
>   return sprintf(outp, "%s%016llx", sep, value);
>  }