diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2018-07-06 11:11:20 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-07-06 14:08:37 -0400 |
commit | 8736715857d08cc1f88d766c257b39c05df20639 (patch) | |
tree | 88d687c08c55aa0bc4a684536d5e32554a5c02ef /rts | |
parent | f03f0d61bebe287e0df0254c175eb2f183d697aa (diff) | |
download | haskell-8736715857d08cc1f88d766c257b39c05df20639.tar.gz |
rts: Enable two-step allocator on FreeBSD
Previously we would prevent any operating system not providing the
MEM_NORESERVE flag
from using the two-step allocator. Afterall, Linux will reserve
swap-space for
a mapping unless this flag is given, which is most certainly not what
we want.
However, it seems that FreeBSD provides the reservation-only mapping
behavior
that we expect despite not providing the MEM_NORESERVE macro. In fact,
it
provided the macro until 2014, when it was removed on account of not
being
implemented in the kernel. However, empirical evidence suggests that
just plain
mmap does what we want.
Reviewers: erikd, simonmar
Subscribers: rwbarton, thomie, erikd, carter
GHC Trac Issues: #15348
Differential Revision: https://phabricator.haskell.org/D4939
Diffstat (limited to 'rts')
-rw-r--r-- | rts/posix/OSMem.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index e63e798be9..08f96350c9 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -102,8 +102,10 @@ void osMemInit(void) The naming is chosen from the Win32 API (VirtualAlloc) which does the same thing and has done so forever, while support for this in Unix systems has only been added recently and is hidden in the posix portability mess. - It is confusing because to get the reserve behavior we need MAP_NORESERVE - (which tells the kernel not to allocate backing space), but heh... + The Linux manpage suggests that mmap must be passed MAP_NORESERVE in order + to get reservation-only behavior. It is confusing because to get the reserve + behavior we need MAP_NORESERVE (which tells the kernel not to allocate backing + space), but heh... */ enum { @@ -161,7 +163,10 @@ my_mmap (void *addr, W_ size, int operation) else prot = PROT_NONE; if (operation == MEM_RESERVE) -# if defined(MAP_NORESERVE) +# if defined(MAP_GUARD) + // Provided by FreeBSD + flags = MAP_GUARD; +# elif defined(MAP_NORESERVE) flags = MAP_NORESERVE; # else # if defined(USE_LARGE_ADDRESS_SPACE) |