Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Aug 2012 08:47:47 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Colin Percival <cperciva@freebsd.org>
Cc:        FreeBSD current <freebsd-current@freebsd.org>
Subject:   Re: Time to bump default VM_SWZONE_SIZE_MAX?
Message-ID:  <86zk5y55rg.fsf@ds4.des.no>
In-Reply-To: <502831B7.1080309@freebsd.org> (Colin Percival's message of "Sun,  12 Aug 2012 15:44:07 -0700")
References:  <502831B7.1080309@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Colin Percival <cperciva@freebsd.org> writes:
> If I'm understanding things correctly, the "maxswzone" value -- set by the
> kern.maxswzone loader tunable or to VM_SWZONE_SIZE_MAX by default -- shou=
ld
> be approximately 9 MiB per GiB of swap space.

Far less, in fact.  As mentioned in loader(8), the default 32 MB limit
is enough for slightly more than 7 GB of swap space - assuming 100%
efficient use of swblocks.  The man page recommends not using more than
half the theoretical limit, or, with 16 pages per swblock,

                          1     maxswzone x s
                         --- x ---------------
                          2          16

where s =3D 276 on 32-bit systems and 288 on 64-bit systems.

> The current default for VM_SWZONE_SIZE_MAX was set in August 2002 to 32 M=
iB;
> meaning that anyone who wants to use more than ~ 3.5 GB of swap space oug=
ht
> to set kern.maxswzone in /boot/loader.conf.
>
> Is it time to increase this default on amd64?  (I understand that keeping=
 the
> value low on i386 is important due to KVA limitations, but amd64 has far =
more
> address space available...)

There is no reason to keep this limit at all.  The algorithm used to
size the zone is "physpages / 2 * sizeof(struct swblock) or maxswzone,
whichever is smaller" where maxswzone =3D=3D VM_SWZONE_SIZE_MAX unless
kern.maxswzone was set in loader.conf.  On amd64, the cutoff point is
slightly below 1 GB of physical memory (233,016 4,096-byte pages), so
the limit doesn't help machines that actually need to conserve memory,
and it hurts machines that have plenty of it and therefore also plenty
of swap (assuming the user followed the old "twice the amount of RAM"
rule of thumb).

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=maxswzone-no-default.diff

Index: sys/boot/common/loader.8
===================================================================
--- sys/boot/common/loader.8	(revision 238711)
+++ sys/boot/common/loader.8	(working copy)
@@ -615,14 +615,16 @@
 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.
+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
 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.
+amount of configured swap exceeds the amount
+supported by the kernel.
 Only change
 this parameter if you need to greatly extend the
 KVM reservation for other resources such as the
Index: sys/amd64/include/param.h
===================================================================
--- sys/amd64/include/param.h	(revision 238711)
+++ sys/amd64/include/param.h	(working copy)
@@ -123,14 +123,6 @@
 #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
  */
 #define	round_page(x)	((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
Index: sys/i386/include/param.h
===================================================================
--- sys/i386/include/param.h	(revision 238711)
+++ sys/i386/include/param.h	(working copy)
@@ -123,14 +123,6 @@
 #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
-
-/*
  * Ceiling on size of buffer cache (really only effects write queueing,
  * the VM page cache is not effected), can be changed via
  * the kern.maxbcache /boot/loader.conf variable.

--=-=-=--



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