headsup: swap_pager.c

Andy Farkas andyf at speednet.com.au
Fri Aug 1 17:28:16 PDT 2003

Poul-Henning Kamp wrote:

> People who do not adjust NSWAPDEV to match their configuration spend
> a lot of RAM on holding the radix bitmap which is 3/4 empty:
> 	critter phk> sysctl kern.malloc | grep -i swap
> 		 SWAP     2   753K    753K        2  64
> 	critter phk> pstat -s
> 	Device          1K-blocks     Used    Avail Capacity
> 	/dev/ad0s1b       1321312        0  1321312     0%
> This is because the radix bitmap gets allocated for the full
> stripe width, but only one quarter of it is actually used.
> Another thing is that striping does not belong in the swap_pager in
> the first place, we have CCD and similar pieces of code for that.

I wasn't going to say anything (you can delete now) but the more I think
about it, the more I think "if it aint broke, dont fix it".

For a start, what do those kern.malloc numbers mean?  Mine are different:

# sysctl kern.malloc | grep -i swap
         SWAP     2    73K    137K       12  64,65536
# pstat -s
Device          1K-blocks     Used    Avail Capacity  Type
/dev/ad0s1b         65536      144    65392     0%    Interleaved
/dev/md0            65104        0    65104     0%    Interleaved
/dev/md1            65104        0    65104     0%    Interleaved
/dev/md2           130208        0   130208     0%    Interleaved
Total              325952      144   325808     0%

I don't understand what the concern about using "a lot of RAM" is when you
yourself say that RAM is cheap. If its affecting KVA or something, then
maybe NSWAPDEV should be added into GENERIC along with an explanation that
tuning it saves memory. If the user^Wadmin is aware of the "problem" then
she can adjust the value when she customises her kernel.

Maybe it should be mentioned somewhere (sysinstall or swapctl.8) that the
*size* of swap also affect the memory footprint of the kernel. The general
rule is to have swap 2x RAM - do people really make huge swapfiles that
never get used?  My box has 512M RAM, my swapfile size is 64M and hardly
used. I don't do crashdumps. Sure, developers will want crashdumps...but
thats different.

So I guess Im saying you could "fix" this issue but just documenting what
effects swapfile metrics have on your RAM.


 :{ andyf at speednet.com.au

        Andy Farkas
    System Administrator
   Speednet Communications

More information about the freebsd-arch mailing list