Created attachment 192425 [details]
patch to sys/vm/swap_pager.c (see comments for description)
On current and on 11.1 when using a large amount of swap, increasing kern.maxswzone does not allow more swap to be used as it used to in 11.0.
A patch is attached which has been tested on AMD64 and ARM64 kernels using 11.1 stable and current. It does the following:
1. If maxswzone is set to less than the system guess (based on RAM), then reduce maxswzone as specified (current behaviour).
2. There is a conditional that could be removed that caps the increase in maxswzone to 8 times the guess based on RAM (lots of swap, but lots is needed for small ARM stuff that has 512MB or 1GB RAM. Also had to increase kern.maxswzone on some of my AMD64 servers with 8GB RAM).
3. An increase is made to the effective maxswzone value used (n in the code) subject to the above conditional (which could be removed).
4. Change a printf statement to give swap sizes in pages and MB when kern.maxswzone is too small for the amount of swap.
5. Add printf indicating the minimum value of kern.maxswzone that will quiet the warning (and presumably allow that amount of swap to be used).
6. Add a conditional that catches the case where the guess at the size of struct swblk in sys/i386/include/param.h is wrong. This code was removed in other architectures so affects i386 only. I added this code temporarily to amd64 to test.
I've been using this patch with no adverse affect on multiple production servers and vm for a few weeks. Given that all it does is allow increase in kern.maxswzone to take effect, it should be safe and should go into 11.2, but at least go into 12.
Adding kib@ to cc as this seems to be related to r323537.
See r341375, https://reviews.freebsd.org/rS341375
markj@ will check if there's something more to do here
I believe most of the original patch is subsumed by r341375. The i386 bit is interesting; the limit we have in i386/include/param.h is bogus and probably makes less sense since the 4/4 split.