Re: BSD VM architecture...

phil-news-nospam_at_ipal.net
Date: 06/05/03


Date: 4 Jun 2003 22:51:34 GMT

On 4 Jun 2003 11:05:42 -0700 Steve H <netspam@shic.co.uk> wrote:

| I've been wondering about a quirky approach to improve the
| performance/capacity ratio for a VM hungry application I'm developing.
| Put simply, I've huge, but sparsely accessed files (which I mmap into
| my process' address space) and a few megs of compact and very
| frequently accessed control structures. When considering going
| multi-user (one set of control structures and many independent files
| to mmap), I'm faced with two options:
|
| * Use 1 process per user (hence each user has lots of VM space
| available without affecting other users) and use inter-process
| communication to access the control structures (which would work, and
| is not restrictive on available VM space as number of concurrent users
| increases, but is pretty slow as a result of heavy inter-process
| communication.)

This solution is more secure. Even if you think you totally trust
every user, I cannot imagine a multi-user system without having some
level of security barriers involved or considered.

| * Use a single process with multiple threads and statically apportion
| VM space between a fixed number of users. This allows more rapid
| access of the control structures, but at the cost of reduced VM space
| available to each user, but seriously restricts scalability.

Unless you get a good 64-bit architecture going. Ultrasparc, Itanium,
Opteron, and the coming PPC-64, are possibilities.

| What I'm considering is a mechanism to allow a single process (maybe
| with multiple threads) to switch between accessing multiple "VM
| spaces" using some custom kernel extension. This idea rests on a few
| assumptions:

You want to switch the various "subspaces" in and out of the VM? You
can do that now. The system call is mmap(). Just make each space be
a file. Leave them open if you have enough file descriptors. You can
also map in just portions of each subspace as needed. I have used this
technique to map files larger than 4GB by calling mmap() on on the
parts I need at a given time. Though I did not, had I run on a system
with a memory model that allowed, and had, more than 4GB of RAM, then
I could have had a file larger than 4GB entirely in RAM, and view it
with a process limited to a maximum VM of 4GB, in chunks smaller than
that (perhaps one 512MB chunk at a time, or perhaps several 1MB chunks).

| 1. It should be relatively simple to extend the VM architecture to
| allow these multiple contexts.

See above. Negotiating space via mmap() might work for you.

| 2. There must be a way around the apparent problem of retaining access
| to the VM space into which the current process' executable data is
| mapped and, of course, retaining the execution stack.

In Linux the usual VM setup you have about 1GB for memory mapping. I don't
know the BSD situation. It's just a matter of using it wisely.

| 3. It must be significantly quicker to switch "VM spaces" than it is
| to use conventional inter-process communication.
| As I find it hard to believe I'm the first person to ponder about this
| idea, I'd like to enquire if anyone knows of any previous documented
| attempts to offer this sort of facility in BSD (or any other Unix-like
| OS, for that mater)
|
| Ideas anyone?

You could also have some portion of address space shared between all
processes for the bulk communication, then use the IPC to send short
messages like "Go access the 1MB buffer at 0x12300000 for operation FOO".
If the amount that needs to be shared to effectively communicate is not
larger than a significant portion of each VM, this should work. If the
work processes are parented from a common process, this is easy to do.
Or you can designate a file to be shared, and open() and mmap() it in
each process. Or if the file needs to be more secure, open() and mmap()
it in a common parent. Descriptor transferring might be another way to
get the file into the hands of each work process w/o compromising the
permissions of the file.

-- 
-----------------------------------------------------------------
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| phil-nospam@ipal.net | Texas, USA | http://ka9wgn.ham.org/    |
-----------------------------------------------------------------


Relevant Pages

  • Re: Two Console Communication (again)
    ... installed Linux for the first time yesterday on some unused FreeBSD partitions, and it is even older than your kernel: ... communication with our child ... then there is copy-on-write and no communication in either direction. ... Then mmap it, and have our chat. ...
    (alt.lang.asm)
  • Re: Two Console Communication (again)
    ... > whatever Linux calls it was introduced in 2.4. ... > communication in either direction. ... > with mmap(). ... Easy to fool with this with your test program, ...
    (alt.lang.asm)
  • Re: reserving memory without allocating it
    ... > page...so there is no need to put undue pressure on the paging system ... The semantics of mmap() work much better on only one machine. ... Attempting to make mmapwork across multiple distributed nodes ... communication inside mmapis a bad idea. ...
    (comp.os.linux.development.system)
  • Re: reserving memory without allocating it
    ... > The semantics of mmap() work much better on only one machine. ... > communication inside mmapis a bad idea. ... > delay for multiple nodes is several orders of magnitude longer ... acts like a cache of the shared memory. ...
    (comp.os.linux.development.system)