Re: An idea for swap partition size vs. swap space size in use handling
Date: Sun, 22 Jan 2023 13:15:14 UTC
On 22 Jan 2023, at 2:42, Mark Millard wrote: > On Jan 22, 2023, at 00:21, Mark Millard <marklmi@yahoo.com> wrote: > >> On Jan 21, 2023, at 23:17, Poul-Henning Kamp <phk@phk.freebsd.dk> wrote: >> >>> -------- >>> Mark Millard writes: >>> >>>> It would be nice if I could have just one swap partition >>>> on a given boot media, one that is more than sufficient >>>> in size for all but the biggest RAM system --but to then >>>> be able to tell the system to just use up to the >>>> recommended swap space size and to ignore any extra swap >>>> space in the swap partition. Why not just reduce the size of the swap partition to the desired size with “gpart resize”? Granted, that requires manual intervention. Mike >>> Last I looked at that code, that is precisely what happens >>> if you add a too big swap-device ? >> >> It produces a notice reporting how much bigger what it is >> using is than what is recommended, if I understand the >> message right. Here is an example were the difference was >> small for an armv7 context: >> >> warning: total configured swap (1003519 pages) exceeds maximum recommended amount (1003072 pages). >> >> Another from a context with a much bigger difference: >> >> warning: total configured swap (2097152 pages) exceeds maximum recommended amount (916632 pages). >> >> These sort of messages are followed by: >> >> warning: increase kern.maxswzone or reduce amount of swap. >> >> But, as I understand, increasing kern.maxswzone makes >> tradoffs with other kernel memory use. man 8 loader >> reports: > > All my references to "man 8 loader" should have been to > "man 8 loader_simp" these days. (Old habit, not yet > replaced.) > >> kern.maxswzone >> Limits the amount of KVM to be used to hold swap metadata, >> which directly governs the maximum amount of swap the >> system can support . . . >> . . . >> 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. >> >> (Note: My understanding is that an "approximately half" is the >> figure shown as the "recommended amount" in the warnings.) >> >> Running out of space for swap metadata can leave the system >> 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. >> >> The wording in man 8 loader is about decreasing kern.maxswzone > > Again. > >> in order to make room for other resources. But the implication >> is that increases leave less room than normal for other >> resources. I try to avoid getting the warnings as I do not have >> knowledge/context to make well-guided tradeoffs for the >> resources. >> >> As I understand, the 2097152 pages vs. 916632 pages example means >> that it was operating with the referenced fragmentation problems >> being more likely. That would not be true if it was just using >> more like the 916632 pages and ignoring the rest. >> >> (I was not suggesting changes to default behavior. I was only >> suggesting being able to put it in a mode where it would have >> used, for example, just around 916632 pages of the swap space.) >> >> >> (Note: Some of the detailed man 8 loader claims that I left out > > Again. > >> seem to not be general to all platforms, despite the wording >> giving no hint of that issue.) > > > > > === > Mark Millard > marklmi at yahoo.com