diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-09-26 10:09:06 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-09-26 11:59:53 -0400 |
commit | 1d1b991ee15e0428be16d1bfad7087051e000bdc (patch) | |
tree | a93d8d4852e611666953a09beb5745e4f302710b | |
parent | 62464071455ea0472903ef1d94833e5eefb8f74e (diff) | |
download | haskell-1d1b991ee15e0428be16d1bfad7087051e000bdc.tar.gz |
rts: Inform kernel that we won't need reserved address space
Trac #14192 points out that currently GHC's two-step allocator results
in extremely large coredumps. It seems like WebKit may have encountered
similar issues and their apparent solution uses madvise(MADV_DONTNEED)
while reserving address space to inform the kernel that the address
space we just requested needs no backing. Perhaps this is used by the
core dump logic to trim out uncommitted pages.
Test Plan: Validate, try core-dumping a compiled executable
Reviewers: austin, erikd, simonmar
Reviewed By: simonmar
Subscribers: rwbarton, thomie
GHC Trac Issues: #14192, #14193
Differential Revision: https://phabricator.haskell.org/D3929
-rw-r--r-- | rts/posix/OSMem.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index 6ccd65ab16..ee727a56c4 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -191,6 +191,19 @@ my_mmap (void *addr, W_ size, int operation) errno = ENOMEM; } } + + if (operation & MEM_COMMIT) { + madvise(ret, size, MADV_WILLNEED); +#if defined(MADV_DODUMP) + madvise(ret, size, MADV_DODUMP); +#endif + } else { + madvise(ret, size, MADV_DONTNEED); +#if defined(MADV_DONTDUMP) + madvise(ret, size, MADV_DONTDUMP); +#endif + } + #else ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0); #endif |