Subject: bin/28374: vmstat(1) reports more pages freed by page daemon than actually are
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <arto@selonen.org>
List: netbsd-bugs
Date: 11/21/2004 08:32:00
>Number:         28374
>Category:       bin
>Synopsis:       vmstat(1) reports more pages freed by page daemon than actually are
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 21 08:32:00 +0000 2004
>Originator:     Arto Selonen
>Release:        NetBSD 2.99.10 from ~20041109 sources
>Organization:
>Environment:
NetBSD blah 2.99.10 NetBSD 2.99.10 (BLAH) #74: Tue Nov  9 10:35:31 EET 2004  blah@blah:/obj/sys/arch/i386/compile/BLAH i386
>Description:
Running 'vmstat -s' produces (among other things):
  1072242 pages freed by daemon
     5059 anonymous pages scanned by daemon
   706468 object pages scanned by daemon

Inspecting code of uvmpd_scan_inactive() in sys/uvm/uvm_pdaemon.c
reveals that the number of pages freed by the *page daemon*
can not be larger than the above anonymous+object pages scanned.

The discrepancy is caused by uvmexp.pdfreed (documented as
'/* number of pages daemon freed since boot */' in
/usr/src/sys/uvm/uvm_extern.h) being incremented by others
than page daemon (or what daemon is it referring to?). A quick grep
reveals that at least the following files seem to contain code
that increments the counter:

/usr/src/sys/uvm/uvm_pager.c
/usr/src/sys/miscfs/genfs/genfs_vnops.c

>How-To-Repeat:
Code inspection:

/usr/src/sys/uvm/uvm_extern.h
/usr/src/usr.bin/vmstat/vmstat.c
/usr/src/sys/uvm/uvm_pdaemon.c
/usr/src/sys/uvm/uvm_pager.c

Run 'vmstat -s', observe that 'pages freed by daemon' is larger
than what page daemon could have freed.
>Fix:
Either change the description of the counter in both uvm_extern.h and
vmstat.c (to eg. 'pages freed'), or use two counters (one for page daemon, one for others). Or describe which daemon is in question, if not page
daemon.