From owner-freebsd-hackers@FreeBSD.ORG Sat Apr 9 19:06:42 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 800AD106566C for ; Sat, 9 Apr 2011 19:06:42 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2EFF38FC15 for ; Sat, 9 Apr 2011 19:06:41 +0000 (UTC) Received: by qyk27 with SMTP id 27so3159103qyk.13 for ; Sat, 09 Apr 2011 12:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=9NLwxQAVTNS4kjzMX0zSOPf1lrVDeKBjqxavwhn63gE=; b=SUBiUPMdJvDybIgt1RRKZjGYdKSMW9FVCHfyUwM3NAGOAGSYUkX2nRSz9EKZkIO8q8 lIRjG5wGWqazMgMXIOIn6VSuJgkyTvDjru8Uy2rWH+aDr7KA+q07+X8FWii6WPK9yeG8 gAg7oTJ4BndwRvc/KpUiFRHdd1Yt6B+lV5Y3g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=vHAJ2f8BcE3zhyYgcOebzmOIMQ5TLM60iYjH13SpKhtC40sWiHhvUwAoTDg8Tl5IZd h6feHARApIMmW3zdUUZ49x7/Dq1HzDFoHUrOo20fIQeQ2smu1xA65I/Nad5cyF8sqGwO TTdNrOl61BxXRh2bcyi3vJkmW9s8BCgy9gucY= MIME-Version: 1.0 Received: by 10.229.63.229 with SMTP id c37mr2927024qci.212.1302376001103; Sat, 09 Apr 2011 12:06:41 -0700 (PDT) Sender: artemb@gmail.com Received: by 10.229.233.195 with HTTP; Sat, 9 Apr 2011 12:06:41 -0700 (PDT) In-Reply-To: References: Date: Sat, 9 Apr 2011 12:06:41 -0700 X-Google-Sender-Auth: LtkubF5CSsarOUIiQl-n-VnLHbw Message-ID: From: Artem Belevich To: Joe Schaefer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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:06:42 -0000 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. =A0I have a few servers that occasiona= lly > 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. =A0About > the only thing I haven't tried is running httpd under djb's softlimit > executable. > Here's my daemon class in login.conf: > > daemon:\ > =A0 =A0 =A0 =A0:memoryuse=3D1g:\ > =A0 =A0 =A0 =A0:datasize=3D1g:\ > =A0 =A0 =A0 =A0:stacksize=3D1g:\ > =A0 =A0 =A0 =A0:tc=3Ddefault: > > 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=3DD. This way datasize limit will still be in effect. --Artem