From owner-freebsd-stable@FreeBSD.ORG Thu Nov 16 22:39:38 2006 Return-Path: X-Original-To: stable@freebsd.org Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49FB916A49E for ; Thu, 16 Nov 2006 22:39:38 +0000 (UTC) (envelope-from ru@rambler-co.ru) Received: from relay0.rambler.ru (relay0.rambler.ru [81.19.66.187]) by mx1.FreeBSD.org (Postfix) with ESMTP id A01F443DCC for ; Thu, 16 Nov 2006 22:38:12 +0000 (GMT) (envelope-from ru@rambler-co.ru) Received: from relay0.rambler.ru (localhost [127.0.0.1]) by relay0.rambler.ru (Postfix) with ESMTP id 457595C64 for ; Fri, 17 Nov 2006 01:37:57 +0300 (MSK) Received: from edoofus.park.rambler.ru (unknown [81.19.65.108]) by relay0.rambler.ru (Postfix) with ESMTP id 220CA5C0E for ; Fri, 17 Nov 2006 01:37:57 +0300 (MSK) Received: (from ru@localhost) by edoofus.park.rambler.ru (8.13.8/8.13.8) id kAGMc0Xb085879 for stable@freebsd.org; Fri, 17 Nov 2006 01:38:00 +0300 (MSK) (envelope-from ru) Date: Fri, 17 Nov 2006 01:38:00 +0300 From: Ruslan Ermilov To: stable@freebsd.org Message-ID: <20061116223800.GA85695@rambler-co.ru> References: <7ad7ddd90611160255m553a471cy41f6c911bdc2a1bf@mail.gmail.com> <20061116150309.GD48412@rambler-co.ru> <20061116191037.GA1515@roadrunner.q.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GvXjxJ+pjyke8COw" Content-Disposition: inline In-Reply-To: <20061116191037.GA1515@roadrunner.q.local> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: No virus found Cc: Subject: Re: systat -vm output showing negative total virtual memory X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2006 22:39:38 -0000 --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 16, 2006 at 08:10:37PM +0100, Ulrich Spoerlein wrote: > Ruslan Ermilov wrote: > > sysctl(8) knows that t_vm is in bytes, but for the other stats > > it thinks they are in pages. "systat -vm" thinks they are all > > in bytes. Here's a fix: >=20 > Thanks!, I applied your patch to RELENG_6 >=20 > 22K active VM and 1K shared? Seems pretty low to me... >=20 Actually, the values are also in pages. Below is a new patch to try. The total amount of virtual memory reported is still insane; I think some objects are included in the stats mistakenly, but I'm not yet sure. %%% Index: sbin/sysctl/sysctl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sbin/sysctl/sysctl.c,v retrieving revision 1.67.2.7 diff -u -p -r1.67.2.7 sysctl.c --- sbin/sysctl/sysctl.c 8 Sep 2006 09:45:35 -0000 1.67.2.7 +++ sbin/sysctl/sysctl.c 16 Nov 2006 22:23:35 -0000 @@ -395,8 +395,8 @@ S_vmtotal(int l2, void *p) "%hu Sleep: %hu)\n", v->t_rq, v->t_dw, v->t_pw, v->t_sl); printf( - "Virtual Memory:\t\t(Total: %luK, Active %lldK)\n", - (unsigned long)v->t_vm / 1024, + "Virtual Memory:\t\t(Total: %lldK, Active %lldK)\n", + (long long)v->t_vm * pageKilo, (long long)v->t_avm * pageKilo); printf("Real Memory:\t\t(Total: %lldK Active %lldK)\n", (long long)v->t_rm * pageKilo, (long long)v->t_arm * pageKilo); Index: usr.bin/systat/vmstat.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.60.2.1 diff -u -p -r1.60.2.1 vmstat.c --- usr.bin/systat/vmstat.c 21 Mar 2006 20:49:50 -0000 1.60.2.1 +++ usr.bin/systat/vmstat.c 16 Nov 2006 22:35:34 -0000 @@ -58,6 +58,7 @@ static const char sccsid[] =3D "@(#)vmstat #include #include #include +#include #include #include #include @@ -135,7 +136,7 @@ static void copyinfo(struct Info *, stru static float cputime(int); static void dinfo(int, int, struct statinfo *, struct statinfo *); static void getinfo(struct Info *); -static void putint(int, int, int, int); +static void putint(intmax_t, int, int, int); static void putfloat(double, int, int, int, int, int); static void putlongdouble(long double, int, int, int, int, int); static int ucount(void); @@ -472,7 +473,7 @@ showkre() putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0); putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0); mvaddstr(STATROW, STATCOL + 53, buf); -#define pgtokb(pg) ((pg) * (s.v_page_size / 1024)) +#define pgtokb(pg) ((intmax_t)(unsigned)(pg) * (s.v_page_size / 1024)) putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 3, 8); putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 11, 8); putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 19, 9); @@ -667,7 +668,8 @@ cputime(indx) =20 static void putint(n, l, lc, w) - int n, l, lc, w; + intmax_t n; + int l, lc, w; { char b[128]; =20 @@ -677,11 +679,11 @@ putint(n, l, lc, w) addch(' '); return; } - snprintf(b, sizeof(b), "%*d", w, n); + snprintf(b, sizeof(b), "%*jd", w, n); if ((int)strlen(b) > w) - snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000); + snprintf(b, sizeof(b), "%*jdk", w - 1, n / 1000); if ((int)strlen(b) > w) - snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000); + snprintf(b, sizeof(b), "%*jdM", w - 1, n / 1000000); addstr(b); } =20 %%% Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --GvXjxJ+pjyke8COw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFXOhIqRfpzJluFF4RAtBHAJsFdI/ctD226z4CiOSs+4saEy5I7QCbBMqb V1Q2XU77i27P9y7IGGaLQiE= =jNC2 -----END PGP SIGNATURE----- --GvXjxJ+pjyke8COw--