vmstat counter "bug"
Bruce M Simpson
bms at spc.org
Thu Jul 31 10:34:28 PDT 2003
Hi Andrew,
On Thu, Jul 31, 2003 at 09:51:32AM -0700, Andrew Kinney wrote:
> I'm sure this is probably just a limitation of the variable type used,
> but when we run a 'vmstat -m' on our 4.8-RELEASE machine, we
> get a negative integer on the "Requests" section of the memory
> totals.
The field you refer to does not exist under -CURRENT's vmstat(8) command.
However, the attached patch should work for you. The bug is caused by
a signed integer and printf format being used for the statistic in question,
totreq. This is just a running total of what the vmstat(8) command is able
to learn from vm_meter.c's exported sysctls.
This is a fairly quick patch but you'll need to apply it from within
/usr/src/usr.bin/vmstat, then run a make obj/make/make install.
I've raised a PR on your behalf with the patch enclosed, it should reach
GNATS any second.
BMS
-------------- next part --------------
--- vmstat.c.orig Thu Jul 31 18:26:36 2003
+++ vmstat.c Thu Jul 31 18:27:00 2003
@@ -758,7 +758,8 @@
register struct malloc_type *ks;
register int i, j;
int len, size, first, nkms;
- long totuse = 0, totfree = 0, totreq = 0;
+ long totuse = 0, totfree = 0;
+ unsigned long totreq = 0;
const char *name;
struct malloc_type kmemstats[MAX_KMSTATS], *kmsp;
char buf[1024];
@@ -862,7 +863,7 @@
totreq += ks->ks_calls;
}
(void)printf("\nMemory Totals: In Use Free Requests\n");
- (void)printf(" %7ldK %6ldK %8ld\n",
+ (void)printf(" %7ldK %6ldK %8lu\n",
(totuse + 1023) / 1024, (totfree + 1023) / 1024, totreq);
}
More information about the freebsd-hackers
mailing list