diff options
author | jimharris <jimharris@FreeBSD.org> | 2013-10-08 15:47:22 +0000 |
---|---|---|
committer | jimharris <jimharris@FreeBSD.org> | 2013-10-08 15:47:22 +0000 |
commit | bb66cfd2ae8464ce44d16ab33621589703029906 (patch) | |
tree | f4b464ac76cec93bda88ecae18628e7a2b88fd08 /sbin | |
parent | 509a7951936691b0bf8b3257febf8fa9a25dbdc0 (diff) | |
download | FreeBSD-src-bb66cfd2ae8464ce44d16ab33621589703029906.zip FreeBSD-src-bb66cfd2ae8464ce44d16ab33621589703029906.tar.gz |
Extend some 32-bit fields and variables to 64-bit to prevent overflow
when calculating stats in nvmecontrol perftest.
Sponsored by: Intel
Reported by: Joe Golio <joseph.golio@emc.com>
Reviewed by: carl
Approved by: re (hrs)
MFC after: 1 week
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/nvmecontrol/perftest.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sbin/nvmecontrol/perftest.c b/sbin/nvmecontrol/perftest.c index a7339bf..15e4975 100644 --- a/sbin/nvmecontrol/perftest.c +++ b/sbin/nvmecontrol/perftest.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <inttypes.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> @@ -45,7 +46,8 @@ __FBSDID("$FreeBSD$"); static void print_perftest(struct nvme_io_test *io_test, bool perthread) { - uint32_t i, io_completed = 0, iops, mbps; + uint64_t io_completed = 0, iops, mbps; + uint32_t i; for (i = 0; i < io_test->num_threads; i++) io_completed += io_test->io_completed[i]; @@ -53,15 +55,15 @@ print_perftest(struct nvme_io_test *io_test, bool perthread) iops = io_completed/io_test->time; mbps = iops * io_test->size / (1024*1024); - printf("Threads: %2d Size: %6d %5s Time: %3d IO/s: %7d MB/s: %4d\n", + printf("Threads: %2d Size: %6d %5s Time: %3d IO/s: %7ju MB/s: %4ju\n", io_test->num_threads, io_test->size, io_test->opc == NVME_OPC_READ ? "READ" : "WRITE", - io_test->time, iops, mbps); + io_test->time, (uintmax_t)iops, (uintmax_t)mbps); if (perthread) for (i = 0; i < io_test->num_threads; i++) - printf("\t%3d: %8d IO/s\n", i, - io_test->io_completed[i]/io_test->time); + printf("\t%3d: %8ju IO/s\n", i, + (uintmax_t)io_test->io_completed[i]/io_test->time); exit(1); } |