Subject: Re: Memory totals under top on 1.6_BETA
To: David Brownlee <abs@formula1.com>
From: Chris Gilbert <chris@paradox.demon.co.uk>
List: current-users
Date: 07/28/2002 21:47:46
--=-os2hku7R8a7DxKJ6RRuZ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 2002-07-25 at 16:25, David Brownlee wrote:
> 	Machine has 1GB of RAM, top reports:
> 
> Memory: 525M Act, 265M Inact, 2316K Wired, 7220K Exec, 635M File, 5056K Free
> 
> 	Ading them all up gives 1439 MB.
> 
> 	Act + Wired + Exec + File + Free = 1174 MB
> 
> 	Am I missing something?

yes top doesn't show all the numbers, the groupings should be:
Act + Inact + Wired + Free (missing pages to be paged)

and
Exec + File (and missing some others, eg Anon, Zero pages, and Reserved
pages, zero and reserved are near constant)

Using the above you've got:
525 + 265 + 2.3 + 5 = 797.3, which is a couple of hundred less then
expected (what does dmesg give as your total available?)
or
7.2 + 635 = 642.5  again not quite there either, the missing chuck being
anon pages normally.

The other place to get figures is:
vmstat -s
but perhaps ain't as handy as top.

If you're really interested try the attached patch. (you might want to
trim the paging and reserved bits out though)

Chris

--=-os2hku7R8a7DxKJ6RRuZ
Content-Disposition: attachment; filename=top.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=top.diff; charset=ISO-8859-15

? sigdesc.h
? machine/.m_netbsd15.c.swp
Index: machine/m_netbsd15.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: /cvsroot/basesrc/usr.bin/top/machine/m_netbsd15.c,v
retrieving revision 1.16
diff -u -p -r1.16 m_netbsd15.c
--- machine/m_netbsd15.c	2002/03/23 01:28:11	1.16
+++ machine/m_netbsd15.c	2002/07/28 20:43:36
@@ -135,10 +135,10 @@ char *cpustatenames[] =3D {
=20
 /* these are for detailing the memory statistics */
=20
-int memory_stats[7];
+int memory_stats[10];
 char *memorynames[] =3D {
-	"K Act, ", "K Inact, ", "K Wired, ", "K Exec, ", "K File, ",
-	"K Free, ",
+	"K Act, ", "K Inact, ", "K Wired, ", "K Paging, ", "K Free, ",
+	"K Anon, ", "K Exec, ", "K File, ", "K Rsvd, ",
 	NULL
 };
=20
@@ -314,9 +314,13 @@ get_system_info(si)
 	memory_stats[0] =3D pagetok(uvmexp.active);
 	memory_stats[1] =3D pagetok(uvmexp.inactive);
 	memory_stats[2] =3D pagetok(uvmexp.wired);
-	memory_stats[3] =3D pagetok(uvmexp.execpages);
-	memory_stats[4] =3D pagetok(uvmexp.filepages);
-	memory_stats[5] =3D pagetok(uvmexp.free);
+	memory_stats[3] =3D pagetok(uvmexp.paging);
+	memory_stats[4] =3D pagetok(uvmexp.free);
+	memory_stats[5] =3D pagetok(uvmexp.anonpages);
+	memory_stats[6] =3D pagetok(uvmexp.execpages);
+	memory_stats[7] =3D pagetok(uvmexp.filepages);
+	memory_stats[8] =3D pagetok(uvmexp.zeropages +
+		uvmexp.reserve_pagedaemon + uvmexp.reserve_kernel);
=20
 	swap_stats[0] =3D swap_stats[1] =3D swap_stats[2] =3D 0;
=20
@@ -361,7 +365,7 @@ get_system_info(si)
 	if (seporig)
 		free(seporig);
=20
-	memory_stats[6] =3D -1;
+	memory_stats[9] =3D -1;
 	swap_stats[3] =3D -1;
=20
 	/* set arrays and strings */

--=-os2hku7R8a7DxKJ6RRuZ--