Re: [PATCH v2] tools/power turbostat: Fix RAPL summary collection on AMD processors
From: calvin . walton
Date: Mon Apr 19 2021 - 19:52:42 EST
On Mon, 2021-04-19 at 14:58 -0500, Terry Bowman wrote:
@@ -3281,7 +3326,7 @@ static int update_msr_sum(struct thread_data *t, struct core_data *c, struct pkg
continue;
ret = get_msr(cpu, offset, &msr_cur);
if (ret) {
- fprintf(outf, "Can not update msr(0x%x)\n", offset);
+ fprintf(outf, "Can not update msr(0x%lx)\n", offset);
This gives a warning when compiled on 32-bit, since turbostat is
compiled with -D_FILE_OFFSET_BITS=64:
turbostat.c: In function 'update_msr_sum':
turbostat.c:3329:42: warning: format '%lx' expects argument of type
'long unsigned int', but argument 3 has type 'off_t' {aka 'long long
int'} [-Wformat=]
3329 | fprintf(outf, "Can not update msr(0x%lx)\n", offset);
| ~~^ ~~~~~~
| | |
| | off_t {aka long long int}
| long unsigned int
| %llx
Easiest fix is probably to cast to (long long int) and use the %llx
format specifier. That should be valid with i686, x32, and amd64
userspace.
Everything else looks fine as far as I can tell, so feel free to add a
Reviewed-by: Calvin Walton <calvin.walton@xxxxxxxxxx>
once you've fixed that warning.
--
<calvin.walton@xxxxxxxxxx>