Module Name: src
Committed By: martin
Date: Sun Jul 17 12:54:56 UTC 2022
Modified Files:
src/usr.bin/vmstat [netbsd-9]: vmstat.c
Log Message:
Pull up following revision(s) (requested by simonb in ticket #1480):
usr.bin/vmstat/vmstat.c: revision 1.255
When operating on core files or /dev/mem when using the -M option,
use 64-bit math to calculate pool sizes. Fixes overflow errors for
pools larger than 4GB and gives the correct output with "vmstat -m"
for in use, total allocation and utilisation numbers.
To generate a diff of this commit:
cvs rdiff -u -r1.227.2.1 -r1.227.2.2 src/usr.bin/vmstat/vmstat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.227.2.1 src/usr.bin/vmstat/vmstat.c:1.227.2.2
--- src/usr.bin/vmstat/vmstat.c:1.227.2.1 Fri Dec 18 12:23:16 2020
+++ src/usr.bin/vmstat/vmstat.c Sun Jul 17 12:54:56 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.227.2.1 2020/12/18 12:23:16 martin Exp $ */
+/* $NetBSD: vmstat.c,v 1.227.2.2 2022/07/17 12:54:56 martin Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
#else
-__RCSID("$NetBSD: vmstat.c,v 1.227.2.1 2020/12/18 12:23:16 martin Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.227.2.2 2022/07/17 12:54:56 martin Exp $");
#endif
#endif /* not lint */
@@ -1570,7 +1570,7 @@ dopool(int verbose, int wide)
{
int first, ovflw;
void *addr;
- long total, inuse, this_total, this_inuse;
+ uint64_t total, inuse, this_total, this_inuse;
struct {
uint64_t pt_nget;
uint64_t pt_nfail;
@@ -1664,8 +1664,8 @@ dopool(int verbose, int wide)
PRWORD(ovflw, " 0x%0*x", 5, 1,
pp->pr_flags | pp->pr_roflags);
- this_inuse = pp->pr_nout * pp->pr_size;
- this_total = pp->pr_npages * pa.pa_pagesz;
+ this_inuse = (uint64_t)pp->pr_nout * pp->pr_size;
+ this_total = (uint64_t)pp->pr_npages * pa.pa_pagesz;
if (pp->pr_roflags & PR_RECURSIVE) {
/*
* Don't count in-use memory, since it's part
@@ -1704,7 +1704,8 @@ dopool(int verbose, int wide)
inuse /= KILO;
total /= KILO;
(void)printf(
- "\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
+ "\nIn use %" PRIu64 "K, "
+ "total allocated %" PRIu64 "K; utilization %.1f%%\n",
inuse, total, (100.0 * inuse) / total);
}