Date: Mon, 12 Nov 2001 15:02:12 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: Terry Lambert <tlambert2@mindspring.com> Cc: Jason Mawdsley <jason@macadamian.com>, freebsd-hackers@FreeBSD.ORG Subject: Re: mmap/madvise Message-ID: <200111122302.fACN2C306926@apollo.backplane.com> References: <200111081947.fA8JlAe03457@web.cs.ndsu.nodak.edu> <02ae01c16891$4c1f4970$2a64a8c0@macadamian.com> <3BEB0A57.3C510C49@mindspring.com> <019401c16959$4e64a8b0$2a64a8c0@macadamian.com> <200111121036.fACAaiv75199@apollo.backplane.com> <3BF05303.FEC66C7A@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
: :Matthew Dillon wrote: :> The small-temporary-file trick is simple: create a small temporary :> file, get a file descriptor to it, remove() the file, then ftruncate() :> the descriptor to the amount of space you need, mmap() it :> MAP_PRIVATE, and close the descriptor. Since it is a private map no :> actual space is allocated for the file, only an inode. You can :> leave the descriptor open if you need to 'allocate' more space using :> additional calls to mmap(). : :One of his original issues was avoiding overcommit. In the file :backed region case, as I suggested in my original response, to :get this behaviour, he would have to touch each of the blocks in :the file following the truncation, to make sure he didn't fall :into an overcommit based failure later. : :-- Terry This example was for anonymous memory, not file-backed memory. mmap()ing the dummy file MAP_PRIVATE means that none of the I/O ever gets to the filesystem or the file, so no blocks are ever allocated (or ever have to be). The only responsible, reasonable, and dependable way to avoid overcommit is to outfit the system according to the type of load you want to place on it, and for the programs being run to be told how far they are allowed to go and to govern themselves using that information. This is going to be true whether you are backing your storage with anonymous memory (swap/phys backed), or whether you are backing it with a pre-written file. Simply using a pre-written file does not really guarentee anything... after all, you can run out of space on the filesystem as easily as you can run out of VM, and if you store other things, like configuration data, in the same filesystem, you are just as vulnerable to bad programming in the event of a write() filesystem-full failure as you are vulnerable to overcomitting the VM system to the point where it starts killing processes. -Matt Matthew Dillon <dillon@backplane.com> 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?200111122302.fACN2C306926>