From owner-freebsd-current@FreeBSD.ORG Sat Jan 5 03:44:02 2008 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 35C4916A473; Sat, 5 Jan 2008 03:44:02 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from mx-out-05.forthnet.gr (mx-out.forthnet.gr [193.92.150.104]) by mx1.freebsd.org (Postfix) with ESMTP id 4AF2313C461; Sat, 5 Jan 2008 03:43:59 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from mx-av-04.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-05.forthnet.gr (8.13.8/8.13.8) with ESMTP id m053Qs5m001018; Sat, 5 Jan 2008 05:26:54 +0200 Received: from MX-IN-05.forthnet.gr (mx-in-05.forthnet.gr [193.92.150.32]) by mx-av-04.forthnet.gr (8.14.1/8.14.1) with ESMTP id m053QsBm009040; Sat, 5 Jan 2008 05:26:54 +0200 Received: from kobe.laptop (ppp5-162.adsl.forthnet.gr [62.1.228.162]) by MX-IN-05.forthnet.gr (8.14.2/8.14.2) with ESMTP id m053QqoY000781; Sat, 5 Jan 2008 05:26:53 +0200 Authentication-Results: MX-IN-05.forthnet.gr smtp.mail=keramida@ceid.upatras.gr; spf=neutral Authentication-Results: MX-IN-05.forthnet.gr header.from=keramida@ceid.upatras.gr; sender-id=neutral Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m053QoG6046933; Sat, 5 Jan 2008 05:26:51 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m053Qm2b046932; Sat, 5 Jan 2008 05:26:48 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 5 Jan 2008 05:26:47 +0200 From: Giorgos Keramidas To: Igor Mozolevsky Message-ID: <20080105032647.GA46843@kobe.laptop> References: <477C82F0.5060809@freebsd.org> <863ateemw2.fsf@ds4.des.no> <20080104002002.L30578@fledge.watson.org> <86bq81c12d.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Sat, 05 Jan 2008 04:26:26 +0000 Cc: Dag-Erling Sm?rgrav , freebsd-current@freebsd.org, Robert Watson , Jason Evans Subject: Re: sbrk(2) broken 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: Sat, 05 Jan 2008 03:44:02 -0000 On 2008-01-04 11:18, Igor Mozolevsky wrote: > On 04/01/2008, Dag-Erling Sm?rgrav wrote: > > Of course, if you're afraid of memory overcommit and you know in advance > > how much memory you need, you can simply allocate a sufficient amount of > > address space at startup and touch it all. This way, you will either be > > killed right away, or be guaranteed to have sufficient memory for the > > rest of your (process) lifetime. Alternatively, do what Varnish does: > > create a large file, mmap it, and allocate everything you need from that > > area, so you have your own private swap space. Just make sure to > > actually allocate the disk space you need (by filling the file with > > zeroes, or at the minimum writing a zero to the file every sb.st_blksize > > bytes, preferably sequentially to avoid excessive fragmentation) > > Surely you can just fseek() on the file at the correct lenght? That would create a nicely sized 'hole' in the starting blocks. What Dag-Erling describes is the correct(TM) way of making sure that all blocks have been allocated from the backing store of the file.