Re: kernel: warning: total configured swap (493567 pages) exceeds maximum recommended amount
- In reply to: void : "Re: kernel: warning: total configured swap (493567 pages) exceeds maximum recommended amount"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 11 Nov 2025 00:27:05 UTC
On Nov 10, 2025, at 15:33, void <void@f-m.fm> wrote:
> On Mon, Nov 10, 2025 at 11:29:10PM +0000, void wrote:
>> Hi,
>>
>> On a newly installed
>> FreeBSD-16.0-CURRENT-arm-armv7-GENERICSD-20251103-088ced14a69b-281661.img
>>
>> unmodified settings 32GB mmcsd.
>>
>> fstab entry for swap is:
>>
>> /dev/label/growfs_swap none swap sw 0 0
>>
>> swap in top shows:
>>
>> Swap: 1928M Total, 1928M Free
>>
>> # sysctl kern.maxswzone
>> kern.maxswzone: 0
>>
>> ???
>>
>> how to fix/should I fix?
>
> Sorry in case it's not obvious, the error is in the subject line:
> "kernel: warning: total configured swap (493567 pages) exceeds maximum recommended amount (493248 pages)."
It is not so much an error message as a waring that the
system might be mistuned, in this case by a small
fraction of the maximum recommend amount:
(493567-493248)/493248 approx.= 0.00064673
Normally the line that you report also has an associated
line that, to me, reads as easily misleading in part:
warning: increase kern.maxswzone or reduce amount of swap.
The warning is not explicit about any tradeoffs involved
for increasing kern.maxswzone . (Personally, I avoid
using combinations that produce the warnings, since I
do not have an understanding of any detailed tradeoffs,
including for leaving things as the messages report. I
have been told in the past that the warning is
associated with an increased risk of deadlock/livelock.
That need not mean that the risk is zero at the maximum
recommended. Also, I've no know way to determine when
such a status is actually contributing to a problem.)
For 64-bit systems, having SWAP=3.6*RAM normally does not
complain. SWAP=4*RAM complains. From build to build the
point for getting warnings moves some in that range.
(This is based on experience, not calculations from what
the kernel code does.) 3.6 was picked to have some
margin.
For 32-bit systems, the factor is notably smaller. If I
remember right SWAP=1.7*RAM has some margin and
SWAP=2*RAM always produces the warnings.
More detailed information based on the man page content
that is related follows. It is from an old Email that
I'd sent out to the lists.
START OLD EMAIL
I'll be more explicit relative to this for how I've
taken that text historically.
QUOTE
kern.maxswzone
Limits the amount of KVM to be used to hold swap meta-
data, which directly governs the maximum amount of swap
the system can support, at the rate of approximately 200
MB of swap space per 1 MB of metadata. This value is
specified in bytes of KVA space. If no value is pro-
vided, the system allocates enough memory to handle an
amount of swap that corresponds to eight times the amount
of physical memory present in the system.
END QUOTE
The TheoreticalMaxSWAP=8*PHYSMEM figure is specific to
64-bit contexts, if I understand right. It is smaller
for 32-bit contexts as far as I can tell. Certainly
the warnings for 32-bit suggest so.
QUOTE
Note that swap metadata can be fragmented, which means
that the system can run out of space before it reaches
the theoretical limit. Therefore, care should be taken
to not configure more swap than approximately half of the
theoretical maximum.
END QUOTE
So, for 64-bit systems, closer to MaxSWAP=4*PHYSMEM.
The warning show up at somewhat less than that. I'd
guess that the kernel's calculations are the more
accurate vs. the above wording.
QUOTE
Running out of space for swap metadata can leave the sys-
tem in an unrecoverable state. Therefore, you should
only change this parameter if you need to greatly extend
the KVM reservation for other resources such as the
buffer cache or kern.ipc.nmbclusters. Modifies kernel
option VM_SWZONE_SIZE_MAX.
END QUOTE
I wonder if "only change the" should be "only increase
the", as only that direction would seem to limit the
space for buffer cache or kern.ipc.nmbclusters or
other such.
Either way, I'd take that wording as contradicting the:
"increase kern.maxswzone" part of:
"warning: increase kern.maxswzone or reduce amount of swap."
wording unless one knows that the buffer cache and
kern.ipc.nmbclusters and such tradeoffs would be
reasonable for the context. I do not have that kind
of knowledge about the tradeoffs.
Someone once told me that the tradeoff was probability
of the kernel deadlocking when trying to manage the
resources. I assume that is accurate but do not know
it for sure.
So, historically I've taken the warning seriously but
always via the "reduce amount of swap" part of it.
END OLD EMAIL
===
Mark Millard
marklmi at yahoo.com