Subject: Re: direct copy() between two proc address spaces
To: Jason Thorpe <firstname.lastname@example.org>
From: Thor Lancelot Simon <email@example.com>
Date: 06/21/2004 19:40:35
On Mon, Jun 21, 2004 at 04:16:40PM -0700, Jason Thorpe wrote:
> On Jun 21, 2004, at 1:55 PM, Jonathan Stone wrote:
> >Would it help if we redefine MAP_ANON|MAP_SHARED mmap()s to allow a
> >valid fd, and use the supplied fd to find the (single,
> >to-be-shared) anon object? Or would that break standards conformance?
> Passing a file descriptor pretty much means the memory is *not*
> anonymous, eh?
No, not really, not if you take "anonymous" to mean "not backed by a
file in the filesystem", which is what I believe most application
programmers take MAP_ANON to mean.
The point is, it'd be nice to be able to use mmap() to do shared
memory between unrelated processes _and guarantee that that memory
wouldn't get paged to a file in the filesystem_, without using mlock()
or other nasty tricks. But of course any file descriptor you hand
mmap is in fact going to cause the region to be backed by the vnodepager,
written back like file cache data, etc. Often you don't want that; and
that's why people resort to sysv shm, with all its hair.
We can pass file descriptors between unrelated processes; mmap() takes a
file descriptor as an argument, but ignores it if MAP_ANON; if we made it
_not_ ignore it, maybe we could get somewhere here -- and even, maybe,
move the sysv shm implementation into a library, which would be kinda cool
all by itself.