total configured swap exceeds maximum

Mark Millard marklmi at yahoo.com
Wed May 22 00:37:18 UTC 2019



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:
> 
>> On 2019-May-19, at 08:33, Wojciech Puchar <wojtek at puchar.net> wrote:
>> 
>>>>> what should i set kern.maxswzone to ? it is 0
>>>>> 
>>>>> # sysctl  kern.maxswzone
>>>>> kern.maxswzone: 0  
>>>> 
>>>> IIRC for amd64 kern.maxswzone=0 represents the maximum allowed.  
>>> so i cannot have more VM than 5*RAM?  
>> 
>> 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):
>> 
>>   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.
> 
> In swap_pager.c
> 
>       /*
>         * Initialize our zone, guessing on the number we need based
>         * on the number of pages in the system.
>         */
>        n = vm_cnt.v_page_count / 2;
>        if (maxswzone && n > maxswzone / sizeof(struct swblk))
>                n = maxswzone / sizeof(struct swblk);
> 
> 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] 
Modified Sat Dec 1 16:50:12 2018 UTC (5 months, 2 weeks ago) by kib 
File length: 75712 byte(s) 
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:	
https://reviews.freebsd.org/D18381



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

Revision 341716 - (view) (download) (annotate) - [select for diffs] 
Modified Sat Dec 8 00:46:05 2018 UTC (5 months, 1 week ago) by kib 
File length: 75745 byte(s) 
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] 
Modified Sat Dec 8 00:48:10 2018 UTC (5 months, 1 week ago) by kib 
File length: 73330 byte(s) 
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 = maxswzone != 0 ? maxswzone / sizeof(struct swblk) :
            vm_cnt.v_page_count / 2;


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



More information about the freebsd-hackers mailing list