Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 May 2019 17:37:03 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        RW <rwmaillists@googlemail.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, Wojciech Puchar <wojtek@puchar.net>
Subject:   Re: total configured swap  exceeds maximum 
Message-ID:  <47795095-3575-4648-93F0-9C9CAFAB1D47@yahoo.com>
In-Reply-To: <20190519174030.0206eb41@gumby.homeunix.com>
References:  <alpine.BSF.2.20.1905191204540.4805@puchar.net> <20190519160033.0b0e47fa@gumby.homeunix.com> <alpine.BSF.2.20.1905191733230.61441@puchar.net> <18598E43-CFB1-4C3C-BC46-A4F0DEB569CF@yahoo.com> <20190519174030.0206eb41@gumby.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 2019-May-19, at 09:40, RW via freebsd-hackers <freebsd-hackers at =
freebsd.org> wrote:

> On Sun, 19 May 2019 08:53:15 -0700
> Mark Millard wrote:
>=20
>> On 2019-May-19, at 08:33, Wojciech Puchar <wojtek@puchar.net> wrote:
>>=20
>>>>> what should i set kern.maxswzone to ? it is 0
>>>>>=20
>>>>> # sysctl  kern.maxswzone
>>>>> kern.maxswzone: 0 =20
>>>>=20
>>>> IIRC for amd64 kern.maxswzone=3D0 represents the maximum allowed. =20=

>>> so i cannot have more VM than 5*RAM? =20
>>=20
>> There is is a kernel memory tradeoff structure to increase in
>> kern.maxswzone being larger as I understand. Quoting "man 8 loader"
>> (but the "eight times" is system/architecture specific and will
>> likely be different):
>>=20
>>   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, 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.
>=20
> In swap_pager.c
>=20
>       /*
>         * Initialize our zone, guessing on the number we need based
>         * on the number of pages in the system.
>         */
>        n =3D vm_cnt.v_page_count / 2;
>        if (maxswzone && n > maxswzone / sizeof(struct swblk))
>                n =3D maxswzone / sizeof(struct swblk);
>=20
> In i386  maxswzone defaults to a specific value and it is possible to
> increase the size. In amd64  maxswzone defaults to 0 which give the
> highest value of n permitted.

The code that you quoted is old in head/ and stable/12/ and
stable/11/ (but has not been updated in release/12.0.0/ or
in release/11.2.0/ ):


/[base]/head/sys/vm/swap_pager.c

Revision 341375 - (view) (download) (annotate) - [select for diffs]=20
Modified Sat Dec 1 16:50:12 2018 UTC (5 months, 2 weeks ago) by kib=20
File length: 75712 byte(s)=20
Diff to previous 340637
Allow to create swap zone larger than v_page_count / 2.

If user configured the maxswapzone tunable, just take the literal
value for the initial zone sizing attempt.  Before, it was only
possible to reduce the zone by the tunable.

While there, correct the message which was not correct when zone
creation rounded the size up.

Reported by:	jmg
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential revision:=09
https://reviews.freebsd.org/D18381



/[base]/stable/12/sys/vm/swap_pager.c

Revision 341716 - (view) (download) (annotate) - [select for diffs]=20
Modified Sat Dec 8 00:46:05 2018 UTC (5 months, 1 week ago) by kib=20
File length: 75745 byte(s)=20
Diff to previous 340333
MFC r341375
:
Allow to create swap zone larger than v_page_count / 2.



/[base]/stable/11/sys/vm/swap_pager.c

Revision 341718 - (view) (download) (annotate) - [select for diffs]=20
Modified Sat Dec 8 00:48:10 2018 UTC (5 months, 1 week ago) by kib=20
File length: 73330 byte(s)=20
Diff to previous 335508
MFC r341375
:
Allow to create swap zone larger than v_page_count / 2.




The new code looks like:

        /*
         * Initialize our zone, taking the user's requested size or
         * estimating the number we need based on the number of pages
         * in the system.
         */
        n =3D maxswzone !=3D 0 ? maxswzone / sizeof(struct swblk) :
            vm_cnt.v_page_count / 2;


=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47795095-3575-4648-93F0-9C9CAFAB1D47>