From owner-freebsd-hackers@FreeBSD.ORG Sat Apr 9 19:17:12 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1CAF6106566C; Sat, 9 Apr 2011 19:17:12 +0000 (UTC) (envelope-from joesuf4@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id B166D8FC15; Sat, 9 Apr 2011 19:17:11 +0000 (UTC) Received: by vxc34 with SMTP id 34so4220195vxc.13 for ; Sat, 09 Apr 2011 12:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=SpMtD8X1AtWAg4WvnTknEbjWvyptB66YyWXepTHFAmc=; b=VC/5CMOehaeieZnUejFs4TCbgSUkGfZjP7pY1501crZrPrTvfAaB8hHQ3gtEnSXB0W IJErnvJ8kQnX8WOFwyYEEnjV0Gfm/yG9TqdCx9BtpeeTrqMyQTyo78UAPaOUhiOBMdtP UonBE5kOU4L8M7IjSfBg6jxB6RIqzaBLDB0aA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BWGKLBoiFbT/sXPQ2fTFZfSZTKN3evU6uCS9ich5IzhIMHlYIkqqIT424E+OoeB/sT u1zlgGUxWflj6bHqbOe6lcDlQSy1S74FHdm0m3KQewIHX7TUBEUjq6uxMnI3JkOFOtA1 HNjesW+7zOTkLeY6Rd+62lOB5J2bVVTGUJ3D0= MIME-Version: 1.0 Received: by 10.52.18.74 with SMTP id u10mr5228263vdd.192.1302376630759; Sat, 09 Apr 2011 12:17:10 -0700 (PDT) Received: by 10.52.187.73 with HTTP; Sat, 9 Apr 2011 12:17:10 -0700 (PDT) In-Reply-To: References: Date: Sat, 9 Apr 2011 15:17:10 -0400 Message-ID: From: Joe Schaefer To: Artem Belevich Content-Type: text/plain; charset=UTF-8 Cc: freebsd-hackers@freebsd.org Subject: Re: imposing memory limits in FreeBSD 8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Apr 2011 19:17:12 -0000 On Sat, Apr 9, 2011 at 3:06 PM, Artem Belevich wrote: > On Sat, Apr 9, 2011 at 10:15 AM, Joe Schaefer wrote: >> While I am thrilled about the newfound zfs stability that upgrading to 8 >> has brought, one of the things that seems to have been dropped is >> support for process memory limits. I have a few servers that occasionally >> run out of swap due to runaway httpd daemons, and the ulimit -m settings >> in the startup scripts we use stopped working upon upgrading from FreeBSD 6. >> >> I've tried fiddling with the daemon class in login.conf to no avail >> either. About >> the only thing I haven't tried is running httpd under djb's softlimit >> executable. >> Here's my daemon class in login.conf: >> >> daemon:\ >> :memoryuse=1g:\ >> :datasize=1g:\ >> :stacksize=1g:\ >> :tc=default: >> >> and proof that `limits` groks the config: >> >> # limits -eHC daemon >> ulimit -t unlimited; >> ulimit -f unlimited; >> ulimit -d 1048576; >> ulimit -s 1048576; >> ulimit -c unlimited; >> ulimit -m 1048576; >> ulimit -l unlimited; >> ulimit -u unlimited; >> ulimit -n unlimited; >> ulimit -b unlimited; >> ulimit -v unlimited; >> ulimit -p unlimited; >> ulimit -w unlimited; >> >> Any tips from admins who have successfully imposed memory constraints in 8.x? > > If I recall it correctly, in -8 malloc defaults to mmap for memory > allocations, so RLIMIT_DATA no longer applies. > You have to set RLIMIT_VMEM, but be careful as that would include > everything mmapped in even if it does not use much of that. rpc.statd > is one example of that -- it mmaps in ~256M but has only ~400K > resident set size. > > Another option would be to make malloc() switch back to sbrk() with > MALLOC_OPTIONS=D. This way datasize limit will still be in effect. Thanks for the tip. My concern is with runaway processes that are pushing the server into swap, so it's pretty easy to pick them out based on what top reports for their SIZE. I'll try the vmem limit and let you know how that works out.