From Tor.Egge@idt.ntnu.no  Mon Dec  2 13:56:01 1996
Received: from pat.idt.unit.no (pat.idt.unit.no [129.241.103.5])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id NAA16668
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 2 Dec 1996 13:55:57 -0800 (PST)
Received: from ikke.idt.unit.no (tegge@ikke.idt.unit.no [129.241.111.65]) by pat.idt.unit.no (8.8.3/8.8.3) with ESMTP id WAA16615 for <FreeBSD-gnats-submit@freebsd.org>; Mon, 2 Dec 1996 22:55:52 +0100 (MET)
Received: (from tegge@localhost) by ikke.idt.unit.no (8.8.3/8.8.3) id WAA01725; Mon, 2 Dec 1996 22:55:52 +0100 (MET)
Message-Id: <199612022155.WAA01725@ikke.idt.unit.no>
Date: Mon, 2 Dec 1996 22:55:52 +0100 (MET)
From: Tor Egge <Tor.Egge@idt.ntnu.no>
Reply-To: Tor.Egge@idt.ntnu.no
To: FreeBSD-gnats-submit@freebsd.org
Subject: vm statistics are bad
X-Send-Pr-Version: 3.2

>Number:         2137
>Category:       bin
>Synopsis:       [vm] systat(1) total vm statistics are bad
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec  2 14:00:02 PST 1996
>Closed-Date:    
>Last-Modified:  Mon Aug 16 20:03:41 UTC 2010
>Originator:     Tor Egge
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Norwegian University of Science and Technology, Trondheim, Norway
>Environment:

	FreeBSD ikke.idt.unit.no 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Sun Dec  1 00:54:34 MET 1996     root@ikke.idt.unit.no:/usr/src/sys-UP/compile/TEGGE  i386

>Description:

	Running systat shows bad values for total virtual memory. e.g.
        In this example, it shows 3274676 KB, while it should be 
	                      77316980216 KB.

---- systat output
    3 users    Load  0.18  0.38  0.20                  Mon Dec  2 18:35

Mem:KB    REAL            VIRTUAL                     VN PAGER  SWAP PAGER
        Tot   Share      Tot    Share    Free         in  out     in  out
Act   25168    3984  4143252     4492  329352 count
All  193988    4820  3274676     6664         pages
--- top output
 last pid:   530;  load averages:  0.14,  0.34,  0.20                   18:36:00
50 processes:  2 running, 48 sleeping
CPU states:  1.2% user,  0.0% nice,  1.2% system,  0.0% interrupt, 97.7% idle
Mem: 151M Active, 8728K Inact, 22M Wired, 8345K Buf, 322M Free
Swap: 685M Total, 64K Used, 685M Free
---- vmtotal structure contents
$1 = {t_rq = 2, t_dw = 0, t_pw = 0, t_sl = 21, t_sw = 0, t_vm = -2145615227, 
  t_avm = 1036180, t_rm = 48722, t_arm = 6262, t_vmshr = 1681, 
  t_avmshr = 1516, t_rmshr = 1217, t_armshr = 1109, t_free = 82113}
----

Using 64 bit numbers, counting the same vm objects, the result is 19329245054,
which means 73735 GB total virtual memory.

>How-To-Repeat:

   run systat.

>Fix:

Use 64 bits arithmetic in showkre() in /usr/src/usr.bin/systat/vmstat.c.
Make space for a 12 digit number showing the total virtual memory.

optional extra change in vmtotal() in /usr/src/sys/vm/vm_meter.c:
	
  By ignoring the objects where object->size == 0x7fffffff, the t_vm field
  in the vmtotal structure will have a low lower value. These objects are of
  type OBJT_VNODE, referencing vnodes of type VBLK and tag VT_UFS, referencing
  inodes for the block devices corresponding to the currently mounted ufs file
  systems. Not ignoring them means adding almost 8192 GB virtual memory for
  each mounted ufs filesystem.

  By ignoring the objects where object->ref_count == 0, you will also 
  reduce the t_vm field somewhat.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Mon May 25 01:04:10 PDT 1998 
State-Changed-Why:  
Awaiting committer 
Responsible-Changed-From-To: freebsd-bugs->tegge 
Responsible-Changed-By: jesper 
Responsible-Changed-When: Sun May 27 16:09:06 PDT 2001 
Responsible-Changed-Why:  
Originator is now a commit'er himself 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=2137 
Responsible-Changed-From-To: tegge->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Apr 25 10:05:48 UTC 2008 
Responsible-Changed-Why:  
tegge has returned his commit bit for safekeeping. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=2137 
>Unformatted:
