By default Linux doesn't actually back the pages allocated with mmap
with any physical memory until the first time they are accessed. However you can force it to do so preemptively by calling mlockall(MCL_CURRENT | MCL_FUTURE)
.
It is a common pattern to create guard pages by mmap
ing memory but not setting any of the access bits. Because these pages are not actually going to be used, it would be nice if mlockall
ignored them and still didn't actually back the pages. Can I assume this? Does the Linux kernel go out of its way to make this true?