From b888f8da8e1e89871371706004b82d2a0f2d74ae Mon Sep 17 00:00:00 2001 From: des Date: Tue, 4 Sep 2012 19:14:57 +0000 Subject: [PATCH] MFH (r239255, r239730): increase maxswzone on i386 and remove it on amd64. git-svn-id: svn://svn.freebsd.org/base/stable/9@240097 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/amd64/include/param.h | 8 -------- sys/boot/common/loader.8 | 31 ++++++++++++++++++++----------- sys/i386/include/param.h | 8 +++++++- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h index 6dbeb4035..9ddcf685b 100644 --- a/sys/amd64/include/param.h +++ b/sys/amd64/include/param.h @@ -122,14 +122,6 @@ #endif #define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ -/* - * Ceiling on amount of swblock kva space, can be changed via - * the kern.maxswzone /boot/loader.conf variable. - */ -#ifndef VM_SWZONE_SIZE_MAX -#define VM_SWZONE_SIZE_MAX (32 * 1024 * 1024) -#endif - /* * Mach derived conversion macros */ diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8 index cbb989132..87f86d5ab 100644 --- a/sys/boot/common/loader.8 +++ b/sys/boot/common/loader.8 @@ -613,17 +613,26 @@ Not all architectures use such buffers; see for details. .It Va kern.maxswzone Limits the amount of KVM to be used to hold swap -meta information, which directly governs the -maximum amount of swap the system can support. -This value is specified in bytes of KVA space -and defaults to 32MBytes on i386 and amd64. -Care should be taken -to not reduce this value such that the actual -amount of configured swap exceeds 1/2 the -kernel-supported swap. -The default of 32MB allows -the kernel to support a maximum of ~7GB of swap. -Only change +metadata, 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 provided, 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. +.Pp +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. +.Pp +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 diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index 6a0495c4c..b494f3509 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -125,9 +125,15 @@ /* * Ceiling on amount of swblock kva space, can be changed via * the kern.maxswzone /boot/loader.conf variable. + * + * 276 is sizeof(struct swblock), but we do not always have a definition + * in scope for struct swblock, so we have to hardcode it. Each struct + * swblock holds metadata for 32 pages, so in theory, this is enough for + * 16 GB of swap. In practice, however, the usable amount is considerably + * lower due to fragmentation. */ #ifndef VM_SWZONE_SIZE_MAX -#define VM_SWZONE_SIZE_MAX (32 * 1024 * 1024) +#define VM_SWZONE_SIZE_MAX (276 * 128 * 1024) #endif /* -- 2.45.0