Address space: what's safe?

Martin Pool mbp at
Fri Mar 7 10:29:44 EST 2003

On  7 Mar 2003, Steve Blackburn <Steve.Blackburn at> wrote:

> The context is the memory management subsystem of Jikes RVM, where
> certain algorithms want as much virtual memory as possible with
> various alignment restrictions etc.  Because we have all sorts of
> constraints about alignments etc, we use mmap to get ourselves the
> memory.  

Is that really necessary?  Can't you just use e.g. posix_memalign?  It
will call mmap in cases where that would give a performance win.

If you do use mmap, you should certainly call it with a NULL address

> mmap does not tell you if a shared library is about to clobber the
> space you just got or you're about to clobber a shared library (at
> least not as far as I can tell!---if it can, then this might be all
> I need).

I think it would be a kernel bug if the kernel allocated overlapping
virtual addresses for a library and a mmap'd file.

Have you really seen this?

> We really want a map of what parts of the address space are free for
> us to mess with, or an interface that tells us what we can't
> use---so we can make our own map.

That shouldn't be necessary.  I guess if you really wanted to know
then you could read /proc/self/mmaps, but needing to do this almost
certainly indicates a design bug.


More information about the linux mailing list