Date: Sat, 18 Sep 2010 08:30:51 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: "Robert N. M. Watson" <rwatson@freebsd.org> Cc: freebsd-hackers@freebsd.org, Fabian Keil <freebsd-listen@fabiankeil.de> Subject: Re: zfs + uma Message-ID: <AANLkTimyBMBM1Bfyz3RjQRoUkEeSPuLEZDb6ws0_XQ-o@mail.gmail.com> In-Reply-To: <F100D77A-CE16-40DE-B441-02E702B12686@FreeBSD.org> References: <4C93236B.4050906@freebsd.org> <4C935F56.4030903@freebsd.org> <alpine.BSF.2.00.1009181221560.86826@fledge.watson.org> <20100918143516.3568f40e@r500.local> <F100D77A-CE16-40DE-B441-02E702B12686@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Sat, Sep 18, 2010 at 6:52 AM, Robert N. M. Watson
<rwatson@freebsd.org> wrote:
>
> On 18 Sep 2010, at 13:35, Fabian Keil wrote:
>
>> Doesn't build for me on amd64:
>>
>> fk@r500 /usr/src/tools/tools/umastat $make
>> Warning: Object directory not changed from original /usr/src/tools/tools/umastat
>> cc -O2 -pipe -fno-omit-frame-pointer -std=gnu99 -fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c umastat.c
>> cc1: warnings being treated as errors
>> umastat.c: In function 'uma_print_bucketlist':
>> umastat.c:234: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'uint64_t'
>> umastat.c:234: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'uint64_t'
>> umastat.c: In function 'uma_print_cache':
>> umastat.c:245: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'u_int64_t'
>> umastat.c:246: warning: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'u_int64_t'
>> umastat.c: In function 'main':
>> umastat.c:416: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'u_int64_t'
>> umastat.c:418: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'u_int64_t'
>> umastat.c:420: warning: format '%llu' expects type 'long long unsigned int', but argument 2 has type 'u_int64_t'
>> umastat.c:426: warning: dereferencing type-punned pointer will break strict-aliasing rules
>> umastat.c:429: warning: dereferencing type-punned pointer will break strict-aliasing rules
>> *** Error code 1
>>
>> Stop in /usr/src/tools/tools/umastat.
>>
>> The attached patch seems to work around the problem, I'm not sure if
>> the casts to void* are better than decreasing the WARN level, though ...
>
> This is a 32-bit/64-bit issue. Probably all pointers printing should be converted to %p, and large integer types to %ju and %jd, perhaps with a cast first to intmax_t or uintmax_t if required.
All types were explicitly declared as u_int64_t, so I'd try this
instead with PRIu64. Very few spots in the code today use void * (and
the ones that do interface with kvm_read(3)).
<OT>
FWIW, kvm_read taking the second argument as unsigned long instead of
void* seems a bit inconsistent:
ssize_t
kvm_read(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes);
ssize_t
kvm_write(kvm_t *kd, unsigned long addr, const void *buf, size_t nbytes);
but that's a different topic to look at later, if it really matters to anyone.
</OT>
Thanks,
-Garrett
[-- Attachment #2 --]
Index: umastat.c
===================================================================
--- umastat.c (revision 212223)
+++ umastat.c (working copy)
@@ -36,6 +36,7 @@
#include <vm/uma_int.h>
#include <err.h>
+#include <inttypes.h>
#include <kvm.h>
#include <memstat.h>
#include <stdio.h>
@@ -230,8 +231,8 @@
}
printf("\n");
- printf("%s}; // total cnt %llu, total entries %llu\n", spaces,
- total_cnt, total_entries);
+ printf("%s}; // total cnt %"PRIu64", total entries %"PRIu64"\n",
+ spaces, total_cnt, total_entries);
}
static void
@@ -242,8 +243,8 @@
int ret;
printf("%s%s[%d] = {\n", spaces, name, cpu);
- printf("%s uc_frees = %llu;\n", spaces, cache->uc_frees);
- printf("%s uc_allocs = %llu;\n", spaces, cache->uc_allocs);
+ printf("%s uc_frees = %"PRIu64";\n", spaces, cache->uc_frees);
+ printf("%s uc_allocs = %"PRIu64";\n", spaces, cache->uc_allocs);
if (cache->uc_freebucket != NULL) {
ret = kread(kvm, cache->uc_freebucket, &ub, sizeof(ub), 0);
@@ -412,11 +413,11 @@
}
printf(" Zone {\n");
printf(" uz_name = \"%s\";\n", name);
- printf(" uz_allocs = %llu;\n",
+ printf(" uz_allocs = %"PRIu64";\n",
uzp_userspace->uz_allocs);
- printf(" uz_frees = %llu;\n",
+ printf(" uz_frees = %"PRIu64";\n",
uzp_userspace->uz_frees);
- printf(" uz_fails = %llu;\n",
+ printf(" uz_fails = %"PRIu64";\n",
uzp_userspace->uz_fails);
printf(" uz_fills = %u;\n",
uzp_userspace->uz_fills);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimyBMBM1Bfyz3RjQRoUkEeSPuLEZDb6ws0_XQ-o>
