Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Mar 2014 04:07:39 +0200
From:      Matthew Rezny <matthew@reztek.cz>
To:        freebsd-hackers@freebsd.org
Subject:   Re: kern.maxswzone
Message-ID:  <2672336.0gB9Ql6EQP@desktop.reztek>
In-Reply-To: <alpine.BSF.2.00.1403081048350.10165@wojtek.tensor.gdynia.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
> i configured 4.7GB swap on 512MB computer and i see in logs
> 
> warning: total configured swap (1249880 pages) exceeds maximum recommended
> amount (986496 pages). warning: increase kern.maxswzone or reduce amount of
> swap.
> 
> 
> fine, but after increasing maxswzone to 60000000 from less than 40
> millions of default, no difference in message
> 
> tried even increasing it more - no effect, same messages
> 
> change is in /boot/loader.conf and it sets properly as sysctl
> kern.maxswzone confirms.
> 
> what's wrong

I hit this issue recently and someone on another list provided a helpful 
patch. I did some digging and determined that everything to do with maxswzone 
is a mess. It's a tuneable that can only be adjusted down, not up. That 
message suggests it should be increased but that's just not possible without 
patching. To add to the confusion, the units are inconsistent between the way 
you set it and what is displayed in the messages. For extra bonus confusion, 
not only is the value you set silently limited, but the default value is 
excessive and is thus silently limited so you don't even know the starting 
point until you look at how it is calculated and limited.

Filing a PR with a better patch is on my todo list, but not near the top. I'd 
like to change it to take pages rather than bytes as that would match the 
messages and it would be more direct. As it is, the amount specified in bytes 
is used to calculate some number of pages, and the number of pages must be a 
multiple of some constant. Do to the way the pages are allocated in chunks, 
the apparent size of a page is 17.25 bytes. So, for your case, you want to set 
maxswzone to at least 21MB after applying the patch. If you just apply the 
patch without setting the value explicitly, then the default of 34.5MB will be 
used, which is more than enough for your memory and swap sizes.


--- /sys/vm/swap_pager.c.orig   Wed Feb 20 00:15:49 2013 -0600
+++ /sys/vm/swap_pager.c   Sat Feb 23 13:08:54 2013 -0600
@@ -546,7 +546,7 @@
     * is typically limited to around 32MB by default.
     */
    n = cnt.v_page_count / 2;
-   if (maxswzone && n > maxswzone / sizeof(struct swblock))
+   if (maxswzone)
            n = maxswzone / sizeof(struct swblock);
    n2 = n;
    swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL,




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2672336.0gB9Ql6EQP>