Subject: Re: Swap overcommit (was Re: Replacement for grep(1) (part 2))
To: None <>
From: Matthew Dillon <>
List: tech-userlevel
Date: 07/15/1999 16:22:41
    Here is what I get from one of BEST's mail & www proxy machines.
    ~dillon/br adds the object size's together.  'swap' and 'default'
    objects refers to unbacked VM objects - and none of the processes running
    fork shared unbacked objects so we don't have to worry about that.  The 
    'swap' designation means that at least one page in the object has been
    assigned swap.  The default designation means that no pages have been 
    assigned swap.  The pages can be dirty or clean.

    Typical /proc/PID/map output looks like this (taken from one of the
    sendmail processes).  The lines I've marked are the ones being counted
    as unbacked/swap-backed VM.  The rest are vnode-backed and not counted.

0x1000     0x4b000           66         0 r-x COW vnode
0x4b000    0x4e000            3         3 rwx COW vnode
0x4e000    0x87000           53        43 rwx COW swap		<---
0x87000    0x373000         738       738 rwx     default	<---
0x2004b000 0x2005a000         2         0 r-x COW vnode
0x2005a000 0x2005c000         2         0 rwx COW vnode
0x2005c000 0x20065000         6         2 rwx COW swap		<---
0x20068000 0x2006d000         3         0 r-x COW vnode
0x2006d000 0x2006e000         1         1 rwx COW vnode
0x2006e000 0x200cc000        70         0 r-x COW vnode
0x200cc000 0x200d0000         4         4 rwx COW vnode
0x200d0000 0x200e7000         8         6 rwx COW swap		<---
0xefbde000 0xefbfe000        14        14 rwx COW swap		<---

    proxy1:/tmp# cat /proc/*/map | egrep 'swap|default' | ~dillon/br

    proxy1:/tmp# pstat -s
    Device      1K-blocks     Used    Avail Capacity  Type
    /dev/sd0b      524288    12596   511628     2%    Interleaved

    This machine has 256MB of ram of which around 200MB is in use, we
    will assume the entire 200MB is used by VM spaces for processes.  It is 
    an active machine with around 205 processes at the time of the test.

    So.  200MB of ram + 12MB of swap = 212MB of actual storage being used
    out of 639MB of total swap-backable VM.

    About a factor of 3.2:1.  Actual swap utilization is sitting at 2%.
    If no overcommit were allowed, and assuming a VMSPACE = REALMEM + SWAP
    model, 200MB of ram would be active and 439MB worth of swap would be 
    either allocated or reserved ( though only 12MB would be actually written,
    that part doesn't change ).  439MB of swap verses 12MB of swap.

    In that scenario, the 512MB of swap I assigned to this machine would be
    dangerously low.

					Matthew Dillon