The mysterious kern.maxswzone

Andrea Venturoli ml at
Mon Jan 21 08:24:05 UTC 2019

On 1/16/19 3:20 AM, Victor Sudakov wrote:
> Dear Colleagues,
> I have a small 11.2-RELEASE-p8 i386 system with 512M swap and 256M RAM:

As other said, "I'm not an expert here", so I'll just add my 2c, hoping 
it helps.

> # swapinfo
> Device          1K-blocks     Used    Avail Capacity
> /dev/mirror/gm0s1b    524288    29656   494632     6%
> I guess it's not an extraordinary amount of swap for this amount of RAM.

I agree it's not.
I usually configure all my machine's swap as RAM x 4: the suggested rule 
is x2, but I don't want it to become x1 if I add more RAM :)

> However, on boot I see the warning:
> warning: total configured swap (131072 pages) exceeds maximum recommended amount (113792 pages).
> warning: increase kern.maxswzone or reduce amount of swap.

Many of my systems show this warning: in general it's harmless and you 
can ignore it.
Furthermore, in your case the two numbers (131072 and 113792) are very 
close, so you are already able to use more than 86% of your swap.

Bottom line is: you need some small amount of RAM to manage swap. This 
small amount of RAM is proportional to the amount of swap you want to be 
able to have. So increasing this value will let you add more swap at the 
cost of some spare RAM.
I would think twice about increasing this, given the small total RAM you 

> # sysctl kern.maxswzone
> kern.maxswzone: 36175872

This is strange: on all my boxes (all 11.2/amd64) kern.maxswzone=0.
If you did not set this manually (where, I don't know), perhaps this is 
an i386 vs amd64 thing.

> I have some questions:
> 1. Where is this kern.maxswzone tunable documented?

Some months ago I looked into this and found no official docs.
However, searching the web, some discussions came up which did shed some 
light: I don't have the link anymore, but I suggest you try and search.

> 2. In what units is it measured? What is 36175872, are these bytes?

I don't know.
I (ignorantly) guess (hope) not: 34.5 MiB does not even come close to 
your swap size and it would look a bit too much to manage it (but I 
might be wrong here).

> 3. How do I calculate kern.maxswzone to suit my amount of RAM and swap?
> 36175872/113792=317.91 which confuses me even more (division with
> remainder?)

Can't help you here.


More information about the freebsd-questions mailing list