Commit 1d1b991e authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

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:
parent 62464071
......@@ -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);
} else {
madvise(ret, size, MADV_DONTNEED);
#if defined(MADV_DONTDUMP)
madvise(ret, size, MADV_DONTDUMP);
ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment