From owner-freebsd-current@FreeBSD.ORG Tue Aug 14 06:50:21 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F3F11065673 for ; Tue, 14 Aug 2012 06:50:21 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 090AE8FC0C for ; Tue, 14 Aug 2012 06:50:20 +0000 (UTC) Received: from ds4.des.no (smtp.des.no [194.63.250.102]) by smtp.des.no (Postfix) with ESMTP id 0F6D76002; Tue, 14 Aug 2012 08:50:20 +0200 (CEST) Received: by ds4.des.no (Postfix, from userid 1001) id DCDC0816C; Tue, 14 Aug 2012 08:50:19 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Sergey Kandaurov References: <7BEE3948-EE35-48C2-B4B1-25E34087A4C4@lists.zabbadoz.net> <201207021036.45567.jhb@freebsd.org> Date: Tue, 14 Aug 2012 08:50:19 +0200 In-Reply-To: (Sergey Kandaurov's message of "Mon, 13 Aug 2012 09:49:38 +0400") Message-ID: <86txw655n8.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: "Bjoern A. Zeeb" , freebsd-current FreeBSD Subject: Re: swp_pager_meta_build DoS printf X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2012 06:50:21 -0000 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sergey Kandaurov writes: > What about this patch? It enables to ratelimit the printf. I have a different patch that just prints one message when swzone is exhausted and another when more space becomes available. However, we might want to combine the two, so that it periodically prints a message as long as swzone is exhausted. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=maxswzone-exhausted.diff Index: sys/vm/swap_pager.c =================================================================== --- sys/vm/swap_pager.c (revision 238711) +++ sys/vm/swap_pager.c (working copy) @@ -1804,6 +1804,7 @@ static void swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk) { + static volatile int exhausted; struct swblock *swap; struct swblock **pswap; int idx; @@ -1847,7 +1848,9 @@ mtx_unlock(&swhash_mtx); VM_OBJECT_UNLOCK(object); if (uma_zone_exhausted(swap_zone)) { - printf("swap zone exhausted, increase kern.maxswzone\n"); + if (atomic_cmpset_rel_int(&exhausted, 0, 1)) + printf("swap zone exhausted, " + "increase kern.maxswzone\n"); vm_pageout_oom(VM_OOM_SWAPZ); pause("swzonex", 10); } else @@ -1856,6 +1859,9 @@ goto retry; } + if (atomic_cmpset_rel_int(&exhausted, 1, 0)) + printf("swap zone ok\n"); + swap->swb_hnext = NULL; swap->swb_object = object; swap->swb_index = pindex & ~(vm_pindex_t)SWAP_META_MASK; --=-=-=--