Re: mmap() versus read()

Russell Coker - mailing lists account (bofh@snoopy.virtual.net.au)
Mon, 09 Mar 98 05:53:16 +1000


>> Hmm? Paging mmap()ed data *is* exactly the same as rereading it from
>> the original file on disk. "Paging" refers to the pulling in of virtual
>> memory pages from any location on disk, not necessarily from the swap
>> file. The difference is only that mapped files get paged from their
>> primary storage, whereas anonymous private data gets paged into and out
>> of swap files.
>>
>Why does Linux page executables from their original location? Isn't that
>slower than putting it into the swapfile because you have to wade through the
>filesystem layer when you need to page in? Or is the penalty for writing it
>into the swap bigger than the filesystem overhead?

Executables are demand paged (pages are not loaded in unless the
application tries to execute code in the page). If we swapped out executable
pages then we could have a situation where calling a subroutine in an
application would cause the OS to run out of swap space and terminate it (not
a good situation).

I think that it all comes down to issues of reliability and size of the
swapper file. It should be faster to page in from the swapper file than to
page in from the executable as there is less seeking (application code pages
will be all over the disk, while the swap partition is 128megs contiguous),
especially if the executable comes from a floppy, NFS, or CD-ROM.

Later versions of OS/2 have an attribute to specify that certain
executables (DLLs that are of comparable usefulness to libc) get swapped out
instead of having the code pages discarded and paged in from file. This
apparently gives good performance gains.

I've seen reports stating that people were investigating the possibility of
making certain file systems page code to the swap partition instead of
discarding and paging in from the executable (for CD-ROM, NFS, and floppy).
If this gets done then it'll be easy to experiment with setting different
types of executables as swappable/discardable and timing the performance
differences.

-- 
-----------------------------------------------------------
In return for "mailbag contention" errors from buggy Exchange
servers I'll set my mail server to refuse mail from your domain.
The same response applies when a message to a postmaster
account bounces.
"Russell Coker - mailing lists account" <bofh@snoopy.virtual.net.au>
-----------------------------------------------------------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu