From owner-freebsd-current@FreeBSD.ORG Mon Aug 13 05:49:40 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 094171065672; Mon, 13 Aug 2012 05:49:40 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id B302C8FC08; Mon, 13 Aug 2012 05:49:39 +0000 (UTC) Received: by obbun3 with SMTP id un3so8588789obb.13 for ; Sun, 12 Aug 2012 22:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=mCRhJC5QAF3jExfUXymF1f8L5F+50Prst5Y40p3+Hfc=; b=KRDz0pA+k3PfA4oluBGEWVU2XgpDiSzRtDXdIgUmjphBnXQYon7vJuahufCTikgisF hVikHevOb/wNUqgG36GkXTbmDaS4gZtJ2v3Qq15pnqwsQOd2FWWpFNSRyzKmKIiOjZKq sBYfT++3Onesr5A9LgYLzgbF1AapoMedNV2oMBxYEoNMKQxEKNzXcx3bnTWOzYFDd0fT xY0u1n+YdqKt4QoZSszn5gG2m1k87KMKrTWDjN3n5n9LdLlqQNskt0yswh/yJ9vhu+70 mIm3G6eGoirh8fvnc58+LLS9wxDgrbY6AjjofFLNbxIKaSik6S3VzJ1/sYD1+t94a2nm MPGg== MIME-Version: 1.0 Received: by 10.50.237.73 with SMTP id va9mr4123948igc.3.1344836978933; Sun, 12 Aug 2012 22:49:38 -0700 (PDT) Received: by 10.64.165.34 with HTTP; Sun, 12 Aug 2012 22:49:38 -0700 (PDT) In-Reply-To: References: <7BEE3948-EE35-48C2-B4B1-25E34087A4C4@lists.zabbadoz.net> <201207021036.45567.jhb@freebsd.org> Date: Mon, 13 Aug 2012 09:49:38 +0400 Message-ID: From: Sergey Kandaurov To: "Bjoern A. Zeeb" Content-Type: text/plain; charset=ISO-8859-1 Cc: 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: Mon, 13 Aug 2012 05:49:40 -0000 On 2 July 2012 20:31, Bjoern A. Zeeb wrote: > > On 2. Jul 2012, at 14:36 , John Baldwin wrote: > >> On Sunday, July 01, 2012 8:23:31 am Bjoern A. Zeeb wrote: >>> Hey, >>> >>> hitting this printf in swp_pager_meta_build() >>> >>> if (uma_zone_exhausted(swap_zone)) { >>> printf("swap zone exhausted, increase kern.maxswzone\n"); >>> vm_pageout_oom(VM_OOM_SWAPZ); >>> pause("swzonex", 10); >>> } else >>> >>> seems to be an effective way to put the machine into a state of no recovery >>> unless the memory situation would be able to clear itself. Not that it wouldn't >>> otherwise be any better but in addition having a couple of tenthousands of these >>> going to console as well is really not helpful to try to do anything either. Can >>> we make it a log() call or something? >>> >>> /bz >>> >>> PS: I am not sure as I have seen it on someone else's machines and it's >>> probably been ZFS that caused it. I unfortunately neither had a way to >>> get back in or break to a kernel debugger, so information is sparse. >> >> This used to be a silent deadlock before I added the printf() and the call to >> OOM. :-P Do you just want to ratelimit the printf? We have an API to ratelimit >> printf's already. > > Ratelimit would be fine; I was writing that on the wrong time of the wrong day to > just get it out; could you do that? Hi, looks like the discussion was abandoned. What about this patch? It enables to ratelimit the printf. Also, are the new variables put in the right places from the style pov? Index: /usr/src/sys/vm/swap_pager.c =================================================================== --- /usr/src/sys/vm/swap_pager.c (revision 239171) +++ /usr/src/sys/vm/swap_pager.c (working copy) @@ -1804,8 +1804,10 @@ restart: static void swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk) { + static struct timeval lastfail; struct swblock *swap; struct swblock **pswap; + static int curfail; int idx; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); @@ -1847,7 +1849,9 @@ retry: mtx_unlock(&swhash_mtx); VM_OBJECT_UNLOCK(object); if (uma_zone_exhausted(swap_zone)) { - printf("swap zone exhausted, increase kern.maxswzone\n"); + if (ppsratecheck(&lastfail, &curfail, 1)) + printf("swap zone exhausted, " + "increase kern.maxswzone\n"); vm_pageout_oom(VM_OOM_SWAPZ); pause("swzonex", 10); } else -- wbr, pluknet