10

It looks to me like MAP_POPULATE is not just for private mappings, in contradiction to what the man page says:

MAP_POPULATE (since Linux 2.5.46) Populate (prefault) page tables for a mapping. For a file mapping, this causes read-ahead on the file. Later accesses to the mapping will not be blocked by page faults. MAP_POPULATE is only supported for private mappings since Linux 2.6.23.

Based on my cursory inspection of the Linux kernel source for mmap.c, it looks like MAP_POPULATE has absolutely no relationship with MAP_PRIVATE whatsoever in versions going back as far as 2.6.34.

Here is an excerpt of the latest code from mmap.c as of the 3.14 kernel implementation:

...
1364         addr = mmap_region(file, addr, len, vm_flags, pgoff);
1365         if (!IS_ERR_VALUE(addr) &&
1366             ((vm_flags & VM_LOCKED) ||
1367              (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
1368                 *populate = len;
1369         return addr;
...

Am I wrong in my observation?

2
  • 1
    I read that remark as "before 2.6.23, MAP_POPULATE was not supported for private mappings" (with no information about MAP_POPULATE for non-private mappings).
    – Fred Foo
    May 6, 2014 at 18:55
  • I guess it can be interpreted that way also. Maybe "they" need to change the language so that it is less ambiguous. May 6, 2014 at 19:37

1 Answer 1

12

The wording has been updated since you asked the question:

Before: MAP_POPULATE is only supported for private mappings since Linux 2.6.23.
After:  MAP_POPULATE is supported for private mappings only since Linux 2.6.23.

In other words, you can use MAP_POPULATE for private mappings, but you need at least Linux 2.6.23.

Hope this clarifies it!

1
  • 11
    I don't think the wording helps with the ambiguity at all. When a colleague and I read this the other day we interpreted it as MAP_POPULATE is supported (for private mappings only) since Linux 2.6.23. That is, it seems to be saying that it only supports private mappings in later versions of the kernel. I'd recommend something like Since Linux 2.6.23 MAP_POPULATE works for both private and shared mappings. Prior to 2.6.23, only shared mappings were supported.
    – Ben Burns
    Mar 3, 2017 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.