From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 31 10:34:28 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D75A37B401 for ; Thu, 31 Jul 2003 10:34:28 -0700 (PDT) Received: from hysteria.spc.org (hysteria.spc.org [195.206.69.234]) by mx1.FreeBSD.org (Postfix) with SMTP id 5A5FC43FA3 for ; Thu, 31 Jul 2003 10:34:27 -0700 (PDT) (envelope-from bms@hysteria.spc.org) Received: (qmail 1349 invoked by uid 5013); 31 Jul 2003 17:31:58 -0000 Date: Thu, 31 Jul 2003 18:31:58 +0100 From: Bruce M Simpson To: Andrew Kinney Message-ID: <20030731173158.GC24526@spc.org> Mail-Followup-To: Bruce M Simpson , Andrew Kinney , freebsd-hackers@freebsd.org References: <3F28E6A4.22314.2255664F@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="KDt/GgjP6HVcx58l" Content-Disposition: inline In-Reply-To: <3F28E6A4.22314.2255664F@localhost> User-Agent: Mutt/1.4.1i cc: freebsd-hackers@freebsd.org Subject: Re: vmstat counter "bug" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2003 17:34:28 -0000 --KDt/GgjP6HVcx58l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --KDt/GgjP6HVcx58l Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="vmstat_totreq.patch" --- 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); } --KDt/GgjP6HVcx58l--