Re: kernel: warning: total configured swap (493567 pages) exceeds maximum recommended amount

From: Mark Millard <marklmi_at_yahoo.com>
Date: Tue, 11 Nov 2025 18:24:47 UTC
On Nov 11, 2025, at 08:58, Dag-Erling Smørgrav <des@FreeBSD.org> wrote:

> bob prohaska <fbsd@www.zefox.net> writes:
>> So I'm flirting with trouble on a system (Pi2/armv7 FWIW) reporting
>> warning: total configured swap (1024000 pages) exceeds maximum recommended amount (467488 pages).
>> warning: increase kern.maxswzone or reduce amount of swap. ?
> 
> The maximum recommended amount is half the maximum supported amount, so
> you not only have more swap than recommended, you have more swap than
> the kernel can actually use (467488 * 2 = 934976 pages) and should
> consider either increasing kern.maxswzone so the kernel can use all of
> the swap you've configured (at the cost of slightly reducing usasble
> physical memory) or decreasing the amount of swap.

Beyond the issue of having more swap than can even be used
under the best-case kind of contexts, given other defaults
in use, there is the following documented property. (In
order to put a copy of the below note with this other
related material.)

QUOTE
man 8 loader_simp reports:

kern.maxswzone
. . .

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

This means that using more than the 467488 pages of swap,
given the default kern.maxswzone (or vm.swzone), runs the
greater risk of having fragmentation in the data structure
lead to running out of space before the swap space is
fully used.

But another paragraph for kern.maxswzone in that man page
reports:

"Running out of space for swap metadata can leave the system
in an unrecoverable state. . . ."

However, if I remember right, you have reported testing with
the swap adjusted to not produce the warning --and still got
the status of losing control and getting no more output to
look at. If so, the above is not directly a solution to the
specific problem. (It still may be a good idea to not be
oddly configured while trying to find a solution to your
active problem.)

That paragraph continues by mentioning other tradeoffs
related to kern.maxswzone adjustments:

". . . 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."

[I wonder if the "only change" wording should explicitly
indicate a specific direction (increase vs. decrease)
instead.]


Side note:
I'll note that FreeBSD updates can change the detailed
467488 figure that is computed some. Using the exact
figure can lead to future warning messages. Leaving
some margin for variation can cut down on this.


===
Mark Millard
marklmi at yahoo.com