|
|
Subscribe / Log in / New account

How about this?

How about this?

Posted Dec 14, 2017 1:49 UTC (Thu) by TheJH (subscriber, #101155)
In reply to: How about this? by wahern
Parent article: MAP_FIXED_SAFE

> In 2017 I don't think there is any good use for MAP_FIXED.

MAP_FIXED is how you properly, safely allocate virtually contiguous VMAs. This includes:
- guard pages for thread stacks
- the different sections for library mappings (you need separate VMAs for code, readonly data, copy-on-write data and zero-initialized data)

Try running strace on any binary that is dynamically linked and/or uses threads, and you should see MAP_FIXED.


to post comments

How about this?

Posted Dec 14, 2017 17:16 UTC (Thu) by zlynx (guest, #2285) [Link] (1 responses)

Some programmers prefer to mmap a large block and then mprotect the pieces of it instead of using MAP_FIXED.

How about this?

Posted Dec 14, 2017 19:30 UTC (Thu) by ballombe (subscriber, #9523) [Link]

This is true, however there is a difference if you use vm.overcommit=2.
Using MAP_FIXED allows the memory not to be counted as committed.
Sometime this is useful.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds