Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vmstat When operating on core files or /dev/mem when...
details: https://anonhg.NetBSD.org/src/rev/4b50ef71e954
branches: trunk
changeset: 368504:4b50ef71e954
user: simonb <simonb%NetBSD.org@localhost>
date: Sat Jul 16 10:36:19 2022 +0000
description:
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.
diffstat:
usr.bin/vmstat/vmstat.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (48 lines):
diff -r 6828d50c3d2b -r 4b50ef71e954 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Sat Jul 16 10:20:21 2022 +0000
+++ b/usr.bin/vmstat/vmstat.c Sat Jul 16 10:36:19 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
#else
-__RCSID("$NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $");
#endif
#endif /* not lint */
@@ -1578,7 +1578,7 @@
{
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;
@@ -1674,8 +1674,8 @@
PRWORD(ovflw, " 0x%0*x", 6, 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
@@ -1714,7 +1714,8 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index