From owner-freebsd-hackers Wed Mar 13 23:24:50 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id C83C937B404 for ; Wed, 13 Mar 2002 23:24:47 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g2E7OTP38934; Wed, 13 Mar 2002 23:24:29 -0800 (PST) (envelope-from dillon) Date: Wed, 13 Mar 2002 23:24:29 -0800 (PST) From: Matthew Dillon Message-Id: <200203140724.g2E7OTP38934@apollo.backplane.com> To: Vladimir Dozen Cc: hackers@freebsd.org, Poul-Henning Kamp , Wilko Bulte , Alfred Perlstein Subject: Re: VM: file swapping (this time in libc): patch References: <200109300752.f8U7qsj41649@earth.backplane.com> <909.1001839737@critter> <20011003233444.A8637@eix.do-labs.spb.ru> <20011004204023.C2422@eix.do-labs.spb.ru> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ok, there are two rather serious problems with this patch: (1) When you use a MAP_PRIVATE mapping, modifications to the mapped memory are backed by swap, not by the file. That is what MAP_PRIVATE does by definition. (2) You can't safely use MAP_SHARED unless you also deal with fork() or you will share what is supposed to be process-private memory across the fork(). -Matt Matthew Dillon :ehlo. : : I was told that diff format I used is unappropriate for most cases, : so I redo it in unified (-u) format. : : Purpose: to allow developers of large applications to use system : memory allocation routines for allocating in mmap()ed file : instead of writing own ones. Also, allow to run applications that : may use huge amount of memory (like Gimp) without reconfiguring : swap. : : Patch description: the patch implements file-backed memory : allocation for regular malloc() routine. If 'F' flag is set : in malloc options, instead of doing mmap(MAP_ANON), malloc() : maps regions from temporal file. File is growed as neccessary, : and new regions are mapped from the same file. : : Details: to avoid using two methods of allocation (brk() and mmap()) in : the same file, regular allocation altered to use mmap(). This : is done by writing emulators (brk_emulator() and sbrk_emulator()). : File allocator uses single descriptor (usually fd==512). File is : created in directory specified by $SWAPDIR, $TMPDIR or "/tmp" : (in this order). $SWAPDIR is introduced since often people use : memory file system for /tmp. Temporal file is unlinked after : creation, so it will be deleted automatically at exit. : : Informal testing shows no performance hit comparing with old-style : brk() allocation, and small hit when using file-backed allocation. : : Here the patch (made on 4.3-RELEASE-p20) :=============================== :--- malloc.c.old Tue Oct 2 12:52:25 2001 :+++ malloc.c Thu Oct 4 20:05:52 2001 :@@ -97,7 +97,7 @@ :... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message