If I mmap a memory region with no access bits set, does mlockall still force it to be backed by physical memory?

117 Views Asked by At

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 mmaping 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?

0

There are 0 best solutions below