Re: Swapping thoughts

Rik van Riel (
Thu, 21 May 1998 11:28:02 +0200 (MET DST)

On Thu, 21 May 1998, Nix wrote:

> > No you don't... Executables are mmap()ed and reside inside
> > the page cache.
> It seems passing strange that executables are treated that way
> but all other files are not.

They are. All mmap()ed files reside in the page cache...

> Why do we have separate code paths for open() & friends?[1] It
> seems that they could be implemented in terms of mmap(), too;

Not completely. For instance, you can't mmap() files larger
than 2GB, while you could open them, if we had a filesystem
supporting this function.
Furthermore, most files in /proc can't be mmap()ed (mmap()ing
/proc/kcore would be a nice case of recursion), the same
goes for most files in /dev and mmap()ing files also costs
some of the (scarce) address space.

> Is this a silly idea? It seems so obvious that I'm sure I'm
> missing something or you'd have done it already.

It's not really silly. You just overlooked the fact that
to some application address space is too scarce to mmap()
all the files they have open. Besides, we need the open()
path anyway, since we sometimes want to open sockets or
character devices.

| Linux: - LinuxHQ MM-patches page | Scouting webmaster |
| - kswapd ask-him & complain-to guy | Vries cubscout leader |
| | <> |

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to