Subject: Questions about uvmext numbers
To: None <current-users@netbsd.org>
From: Monroe Williams <monroe@pobox.com>
List: current-users
Date: 03/17/2003 10:49:03
I recently set up a graph of memory usage on a NetBSD-current machine, and
I've noticed that something just doesn't seem to add up.

There was a short thread on current-users circa July 2002 on this subject
(in the context of the totals displayed in 'top'), but after reading it I
still find myself confused.

The graph (based on one of the example scripts on the 'rrdtool' gallery
pages) shows free, wired, active, and inactive counts as a "stacked" area
graph.  The part I'm confused about is that the total height of the graph
(i.e. free + wired + active + inactive) varies over time by more than 20MB
on a machine with 1GB physical memory.  Similar graphs I've set up on other
machines (NetBSD 1.5ZC macppc, NetBSD 1.5.2 i386, and FreeBSD 4.3 i386)
don't show noticable variation in this total.

(I haven't included "pages paging" in the total, since I've never managed to
catch it at any value except zero.  Pages should never remain in this state
for long, right?)

While the machine (NetBSD-macppc running a 1.6P kernel) was mostly idle, I
repeated 'vmstat -s |grep pages' until the numbers stopped changing each
time.  Here's what I got:

-----
   254162 pages managed
   199844 pages free
    34459 pages active
      715 pages inactive
        0 pages paging
      710 pages wired
        0 zero pages
        1 reserve pagedaemon pages
        5 reserve kernel pages
     6301 anonymous pages
    29940 cached file pages
     2205 cached executable pages
       64 minimum free pages
       85 target free pages
        0 target inactive pages
    84720 maximum wired pages
   256283 swap pages
        0 swap pages in use
        0 pages swapped in
        0 pages swapped out
        0 faults had to wait on pages
        0 pages freed by daemon
        0 pages scanned by daemon
        0 anonymous pages scanned by daemon
        0 object pages scanned by daemon
        0 pages reactivated
        0 pages found busy by daemon
        0 pages deactivated
-----

Here are my questions:

1) Should the total (free + active + inactive + paging + wired) remain
constant once the system is booted?

2) What other invariants should hold, if any?

3) There doesn't seem to be any combination of other numbers that adds up to
the "pages managed" value, or even anything particularly close to it.
Should there be?

4) Can someone explain (briefly) what the various categories really mean, or
point me to doumentation that does?  (Assume I don't know anything about
NetBSD UVM internals, aside from basic concepts.)

5) I assume that each physical page belongs to various categores, with
certain constraints.  What are these constraints?  (I'm looking for
something like "each page must belong to one of
{free|active|inactive|paging|wired} and may belong to at most one of
{anon|file|exec}", but more correct. ;)

Trying to get more educated,
-- monroe
------------------------------------------------------------------------
Monroe Williams                                         monroe@pobox.com