From owner-freebsd-current@FreeBSD.ORG Fri Jan 4 11:30:24 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 9C6FE16A421 for ; Fri, 4 Jan 2008 11:30:24 +0000 (UTC) (envelope-from mozolevsky@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by mx1.freebsd.org (Postfix) with ESMTP id E1C2213C474 for ; Fri, 4 Jan 2008 11:30:23 +0000 (UTC) (envelope-from mozolevsky@gmail.com) Received: by ug-out-1314.google.com with SMTP id y2so3603179uge.37 for ; Fri, 04 Jan 2008 03:30:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=gup2pBSTdu+kXZ1uwYSOCBDvBTE5v1msKMfIaje5iuA=; b=UotGhPUIpU2qJ9gmPmMPPzw5rJFaN+jquJ7N8f0x/9aIyayLx4p37ygH2PRv5PbL6blvrCwVrtAxtpyZPYG4k/QsDBGg67s7XfNT+Dj/OT6U6ahp+5SD4AjjSkoQzQUMER4O17hxYQTW0XvUX6tnldTgacG5vTRt12gAi1v4+24= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ELhzcmkgCcLcObPvA4nURsxQPNv6AQZ5mvDzTRlYvc8sA7pIMRKILgIEFAfWHZrzgCJ1f5+kZ3AkmawkuP0A62oEFS2rGvP6n0Rbr8vBghi7cEKPe32cQawM2KXz9EiAOIrrsjE5+DTmLrmFnCysuMN+MxB0Y3fW9qJwfy2ThjA= Received: by 10.66.252.17 with SMTP id z17mr4222279ugh.50.1199446222499; Fri, 04 Jan 2008 03:30:22 -0800 (PST) Received: by 10.66.248.11 with HTTP; Fri, 4 Jan 2008 03:30:22 -0800 (PST) Message-ID: Date: Fri, 4 Jan 2008 11:30:22 +0000 From: "Igor Mozolevsky" Sender: mozolevsky@gmail.com To: "Robert Watson" In-Reply-To: <20080104111938.N77222@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <477C82F0.5060809@freebsd.org> <863ateemw2.fsf@ds4.des.no> <20080104002002.L30578@fledge.watson.org> <86bq81c12d.fsf@ds4.des.no> <20080104111938.N77222@fledge.watson.org> X-Google-Sender-Auth: 6f7b5e09b60b8fac Cc: =?ISO-8859-1?Q?Dag-Erling_Sm=F8rgrav?= , freebsd-current@freebsd.org, 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: Fri, 04 Jan 2008 11:30:24 -0000 On 04/01/2008, Robert Watson wrote: > On Fri, 4 Jan 2008, Igor Mozolevsky 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 will create a sparse file without file system blocks to back it, and is > effectively also over-commit. When the file system runs out of room, you will > get SIGSEGV when the vnode pager discovers it can't write a page to disk. If > you zero-fill it, the blocks are pre-allocated. Surely you should not be allowed to overcommit on fseek() followed by write(,,1); zeroing out gigs of hdd space seems rather silly... Igor