Time to bump default VM_SWZONE_SIZE_MAX?

Peter Jeremy peter at rulingia.com
Mon Aug 13 21:23:23 UTC 2012


On 2012-Aug-12 15:44:07 -0700, Colin Percival <cperciva at freebsd.org> wrote:
>If I'm understanding things correctly, the "maxswzone" value -- set by the
>kern.maxswzone loader tunable or to VM_SWZONE_SIZE_MAX by default -- should
>be approximately 9 MiB per GiB of swap space.

I'm not sure how you got that value.  By default, struct swblock is
288 bytes (280 bytes on 32-bit archs) and can store up to 32 pages of
swap (the comment in vm/swap_pager.c:swap_pager_swap_init() is wrong).
For x86, this is 2.25 MiB per GiB (best case).

>The current default for VM_SWZONE_SIZE_MAX was set in August 2002 to 32 MiB;
>meaning that anyone who wants to use more than ~ 3.5 GB of swap space ought
>to set kern.maxswzone in /boot/loader.conf.

In practice, you can't fully populate each swblock.  I did a test on
my amd64 box by running multiple copies of a program that allocates
and dirties a big chunk of RAM and then pause()s.  That gave me a 90%
swblock utilisation - which I suspect is higher than a typical
scenario where memory pressure pushes more randomly unused pages out.

Realistically, I'd say that the default VM_SWZONE_SIZE_MAX can handle
about 9GB swap (at least, that was my experience).

BTW, if you plan on allocating lots of swap, be aware that each swap
device is limited to 32GiB - see vm/swap_pager.c:swaponsomething().

-- 
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20120813/c608f5ae/attachment.pgp


More information about the freebsd-current mailing list