Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2002 23:24:29 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Vladimir Dozen <vladimir-dozen@mail.ru>
Cc:        hackers@freebsd.org, Poul-Henning Kamp <phk@critter.freebsd.dk>, Wilko Bulte <wkb@freebie.xs4all.nl>, Alfred Perlstein <bright@mu.org>
Subject:   Re: VM: file swapping (this time in libc): patch
Message-ID:  <200203140724.g2E7OTP38934@apollo.backplane.com>
References:  <200109300752.f8U7qsj41649@earth.backplane.com> <909.1001839737@critter> <20011003233444.A8637@eix.do-labs.spb.ru> <20011004204023.C2422@eix.do-labs.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
    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 
					<dillon@backplane.com>
: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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203140724.g2E7OTP38934>