From owner-freebsd-current@FreeBSD.ORG Thu Aug 23 15:48:28 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 540711065676 for ; Thu, 23 Aug 2012 15:48:28 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 272398FC0A for ; Thu, 23 Aug 2012 15:48:27 +0000 (UTC) Received: by pbbrp2 with SMTP id rp2so1733921pbb.13 for ; Thu, 23 Aug 2012 08:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=TjehiaMDmTYOzH+hhF2FCCsSfclkQL6LsIwC3Eaear8=; b=Nb0DkC0kswK6spI29qwJrDP8g3QKg42FwzuaBIYAAcVe5dNWcyrmvs+ZfMAQpE/661 yfa8u5vZ3dcWcI90U6FeNAe0AtgwRBQEO9Yjgy/RTOiyAPC1PaPgIP+jverIYSKKvzk2 W09jHX9yUgWU0svmIaRh8dZT1ug+T9qisVijhjXPU+yzTPfBrtvBSy6vcb+9vK1ypCRD CKUFi2k141l8/CrhqWewhgwUvFdtZ6vwyzkfY99xFdT603fRrLuw22md2XVT8GiWfPJF vxY79tvFYadxi5I2f1zI2J+F24F0DmAw+ghN2rFJ0adOU5TMXLDguG2+E3ycy76OG7jU 2/6A== MIME-Version: 1.0 Received: by 10.68.241.65 with SMTP id wg1mr5835411pbc.25.1345736907770; Thu, 23 Aug 2012 08:48:27 -0700 (PDT) Received: by 10.68.217.40 with HTTP; Thu, 23 Aug 2012 08:48:27 -0700 (PDT) In-Reply-To: <20120822120105.GA63763@onelab2.iet.unipi.it> References: <20120822120105.GA63763@onelab2.iet.unipi.it> Date: Thu, 23 Aug 2012 10:48:27 -0500 Message-ID: From: Alan Cox To: Luigi Rizzo Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: current@freebsd.org Subject: Re: less aggressive contigmalloc ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Aug 2012 15:48:28 -0000 On Wed, Aug 22, 2012 at 7:01 AM, Luigi Rizzo wrote: > I am trying to make netmap adapt the amount of memory it allocates > to what is available. At its core, it uses contigmalloc() with > small chunks (even down to 1 page) to fetch memory. > > Problem is, i notice that before failing, contigmalloc() > tries to swap out some processes (effectively killing them > because i have no swap configured in my picobsd image). > This happens with both M_WAITOK and M_NOWAIT, the difference > is only in the number of retries it does -- see e.g. > > sys/vm/vm_kern.c :: kmem_alloc_contig() > > where it retries once for M_NOWAIT and 3 times for M_WAITOK. > > I wonder if there is a way to make contigmalloc less aggressive > and fail without killing those innocent processes ? > > Have you actually observed processes being killed with M_NOWAIT? The difference between M_NOWAIT and M_WAITOK is more than just the number of retries. Each successive iteration is more aggressive in its attempt to recover pages. On the first iteration, no pages should be written to swap. Nothing should happen that could result in process termination. Alan