From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 30 02:07:50 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E8F4D2A7 for ; Sun, 30 Mar 2014 02:07:50 +0000 (UTC) Received: from mail.modirum.com (mail.modirum.com [31.185.27.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7B5B3A1 for ; Sun, 30 Mar 2014 02:07:49 +0000 (UTC) Received: from 93-153-61-159.tmcz.cz ([93.153.61.159] helo=desktop.reztek) by mail.modirum.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1WU59w-0001nL-Is for freebsd-hackers@freebsd.org; Sun, 30 Mar 2014 02:07:40 +0000 From: Matthew Rezny To: freebsd-hackers@freebsd.org Subject: Re: kern.maxswzone Date: Sun, 30 Mar 2014 04:07:39 +0200 Message-ID: <2672336.0gB9Ql6EQP@desktop.reztek> Organization: RezTek, s.r.o. User-Agent: KMail/4.12.3 (FreeBSD/10.0-STABLE; KDE/4.12.3; amd64; ; ) In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-SA-Authenticated: Yes X-SA-Exim-Connect-IP: 93.153.61.159 X-SA-Exim-Mail-From: matthew@reztek.cz X-SA-Exim-Scanned: No (on mail.modirum.com); SAEximRunCond expanded to false X-Mailman-Approved-At: Sun, 30 Mar 2014 02:23:52 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Mar 2014 02:07:51 -0000 > i configured 4.7GB swap on 512MB computer and i see in logs > > warning: total configured swap (1249880 pages) exceeds maximum recommended > amount (986496 pages). warning: increase kern.maxswzone or reduce amount of > swap. > > > fine, but after increasing maxswzone to 60000000 from less than 40 > millions of default, no difference in message > > tried even increasing it more - no effect, same messages > > change is in /boot/loader.conf and it sets properly as sysctl > kern.maxswzone confirms. > > what's wrong I hit this issue recently and someone on another list provided a helpful patch. I did some digging and determined that everything to do with maxswzone is a mess. It's a tuneable that can only be adjusted down, not up. That message suggests it should be increased but that's just not possible without patching. To add to the confusion, the units are inconsistent between the way you set it and what is displayed in the messages. For extra bonus confusion, not only is the value you set silently limited, but the default value is excessive and is thus silently limited so you don't even know the starting point until you look at how it is calculated and limited. Filing a PR with a better patch is on my todo list, but not near the top. I'd like to change it to take pages rather than bytes as that would match the messages and it would be more direct. As it is, the amount specified in bytes is used to calculate some number of pages, and the number of pages must be a multiple of some constant. Do to the way the pages are allocated in chunks, the apparent size of a page is 17.25 bytes. So, for your case, you want to set maxswzone to at least 21MB after applying the patch. If you just apply the patch without setting the value explicitly, then the default of 34.5MB will be used, which is more than enough for your memory and swap sizes. --- /sys/vm/swap_pager.c.orig Wed Feb 20 00:15:49 2013 -0600 +++ /sys/vm/swap_pager.c Sat Feb 23 13:08:54 2013 -0600 @@ -546,7 +546,7 @@ * is typically limited to around 32MB by default. */ n = cnt.v_page_count / 2; - if (maxswzone && n > maxswzone / sizeof(struct swblock)) + if (maxswzone) n = maxswzone / sizeof(struct swblock); n2 = n; swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL,