Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Aug 2012 08:50:19 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Sergey Kandaurov <pluknet@gmail.com>
Cc:        "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>, freebsd-current FreeBSD <freebsd-current@freebsd.org>
Subject:   Re: swp_pager_meta_build DoS printf
Message-ID:  <86txw655n8.fsf@ds4.des.no>
In-Reply-To: <CAE-mSO%2BXH36yyvSyaHU7bNAzDS___C=zwriAaeT6p6itbbKYNw@mail.gmail.com> (Sergey Kandaurov's message of "Mon, 13 Aug 2012 09:49:38 %2B0400")
References:  <7BEE3948-EE35-48C2-B4B1-25E34087A4C4@lists.zabbadoz.net> <201207021036.45567.jhb@freebsd.org> <B60059D0-9ED8-430D-8D7D-275E4536AC94@lists.zabbadoz.net> <CAE-mSO%2BXH36yyvSyaHU7bNAzDS___C=zwriAaeT6p6itbbKYNw@mail.gmail.com>

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

Sergey Kandaurov <pluknet@gmail.com> 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;

--=-=-=--



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