How to reserve address space without actual backing store
This is more or less a userspace API question, but the documentation I've found in manpages does not match actual kernel behavior, so I'm asking here.
With vm.overcommit_memory and address space randomization, a lot of applications (particularly those who use certain types of garbage collectors) need a way to reserve a chunk of the address space, without actually counting towards the vm.overcommit_memory limit. Typically, you want to allocate all the heap in a single, continuous range. As the heap usage increases, you gradually allocate backing store from the kernel. (Without address space randomization, you can use some heuristics to avoid DSO space etc. and use MAP_FIXED to grow the heap as needed, I suppose.)
MAP_NORESERVE does not work for this purpose because memory allocated that way still counts as comitted. What seems to work is to reserve address space with PROT_NONE, and later use mprotected to get backing store. My question is if this is an accident, or if this approach is guaranteed to work in the future.
(mprotect to subsequently add PROT_EXEC has been broken on some architectures unless you take special measures, so I guess that this is genuine concern.)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>