From: Matt Miller <mmiller@hick.org>
To: linux-kernel@vger.kernel.org
Cc: mmiller@hick.org
Subject: Re: [PATCH] 2.6: mmap complement, fdmap
Date: Mon, 22 Mar 2004 22:26:03 -0600 (CST) [thread overview]
Message-ID: <Pine.LNX.4.58.0403221900480.131@jethro.hick.org> (raw)
In-Reply-To: <20040323005204.GF8366@waste.org>
On Mon, 22 Mar 2004, Matt Mackall wrote:
> On Mon, Mar 22, 2004 at 01:26:01PM -0600, Matt Miller wrote:
> > > How about tmpfs/ramfs instead? Open a file on tmpfs and mmap it and
> > > you've got the same thing without any of the nasty corner cases.
> >
> > Because tmpfs does not allow you to map a file descriptor to a specific
> > memory
> > range inside a process. tmpfs allows you to open a file that exists only
> > in memory, yes, but it does not accomplish what fdmap tries to accomplish.
> > fdmap allows you to access arbitrary memory ranges as if they were a file.
> > tmpfs allows you to access a file that happens to only exist in memory.
> > You do not control the address range that tmpfs/ramfs map to.
>
> You don't? Is this not what the first argument of mmap provides? I'm
> afraid I can't see how it matters, as you'd have to populate said map
> afterwards anyway.
Disadvantages with tmpfs/ramfs:
1. mountpoint requirement for user-mode access.
2. proper file permission controls for non-root user access.
3. mapping an arbitrary memory range to a file descriptor requires
opening a file and copying the memory to it via write or mmap on
tmpfs/ramfs.
Advantages of fdmap:
1. none of the above three problems.
2. more optimized due to the avoidance of open/write/lseek associated
with using tmpfs to map an arbitrary memory range, such as user
stack.
3. acts as a logical complement to mmap; read below for why.
4. others I've listed previously.
I am not at all discounting that tmpfs/ramfs are useful. They are quite
useful. However, I'm stating that they do not completely accomplish what
fdmap accomplishes due to a differing approach. The underlying difference
can be defined in terms of one, fdmap, being able to map arbitrary memory
ranges in the context of the process to a file descriptor without having
to synchronize the file to 'disk' (whether the disk be a tmpfs emulated
file system or an actual harddrive). The synchronization part involves a
copying of the memory in the case of tmpfs/ramfs. In fdmap, it does not.
> Point is, mmap() is already its own complement and what you're
> proposing is a hairy solution in search of a problem as the VFS
> maintainer already pointed out.
mmap is not its own complement. If it were you would be able to
associate an arbitrary memory range, such as a user thread stack, with a
file descriptor (and no, /proc/self/mem does not count). The point is
that you cannot do this, and as such you need a solution like fdmap.
How is it a hairy solution? Other than the unix domain socket passing of
file descriptors (which I grant you is an odd case), I don't think there
are any problems that I've run into which are that tough to solve with
regards to fdmap's implementation and design.
I would like to hear other's opinions on supporting fd passing between
tasks. Problems I see:
1. Process A passes an fdmap'd fd to process B. If B does a write() on
the file descriptor, should that update memory in A?
2. If it should update memory in A, now we have a potential race
condition:
a. Qauntum expires on B just as it is about to call write on the fd.
Meanwhile, A exits completely. What will happen when B is
rescheduled?
One interesting side effect to this is that it could be used as another
form of IPC (note, emphasis on could, not should). Granted, this is very
much similar to shmem, but reached via a different mechanism. Just a
thought, but not much of one.
Matt
prev parent reply other threads:[~2004-03-23 4:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-22 4:43 Matt Miller
2004-03-22 5:30 ` viro
2004-03-22 6:14 ` Matt Miller
2004-03-22 19:00 ` Matt Mackall
2004-03-22 19:26 ` Matt Miller
2004-03-23 0:52 ` Matt Mackall
2004-03-23 4:26 ` Matt Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0403221900480.131@jethro.hick.org \
--to=mmiller@hick.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®