On Wed, 14 Feb 2018 20:39:12 +0100
Ricardo Wurmus <rek...@elephly.net> wrote:
> Nor do I see this message:
> ghc-pkg: unable to decommit memory: Invalid argument
Which Linux kernel version does this run on?
> I don’t know what this message means, but the messages about requiring a
If there's large address space support , ghc 8 does its own allocation in a
1 TB address space. That means it has to tell the kernel when it doesn't
need some chunk anymore - otherwise you're gonna run out of memory.
It does that using madvise(2). There's two ways it tries to do that:
(1) MADV_FREE: Signals that "I don't need that range at all anymore".
It usually means Linux will mark those pages free.
(2) MADV_DONTNEED: Signals that "I don't need that range in the NEAR FUTURE".
It usually means Linux will swap those pages out.
MADV_FREE was added in Linux 4.5. Haskell uses a #ifdef to detect it.
Newer glibc (such as the one in core-updates) unconditionally define MADV_FREE
to prevent programs from depending on a specific Linux kernel in this way .
There's a patch to ghc that falls back to (2) if (1) doesn't work:
... but ghc 8.0.2 which we have on core-updates doesn't use it.
It uses either MADV_FREE or MADV_DONTNEED, determined at compile time.
So if the Linux kernel is < 4.5 that's gonna end very badly.
For the record:
mmap has a flag MAP_HUGETLB which would cause it to use a mounted
hugetlbfs (the cgroup of which I advised to remove from GuixSD
from the time being). ghc 8 does not use it so we are safe there.
if test "$ac_cv_sizeof_void_p" -eq 8 ; then
if test "x$EnableLargeAddressSpace" = "xyes" ; then
if test "$ghc_host_os" = "darwin" ; then
elif test "$ghc_host_os" = "openbsd" ; then
# as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with
# The flag MAP_NORESERVE is supported for source compatibility
# but is completely ignored by OS mmap
AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],,,
if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
if test "$use_large_address_space" = "yes" ; then
AC_DEFINE([USE_LARGE_ADDRESS_SPACE], , [Enable single heap address space
EINVAL addr is not page-aligned or length is negative.
EINVAL advice is not a valid.
EINVAL advice is MADV_DONTNEED or MADV_REMOVE and the specified address
range includes locked, Huge TLB pages, or VM_PFNMAP pages.
EINVAL advice is MADV_MERGEABLE or MADV_UNMERGEABLE, but the kernel was
not configured with CONFIG_KSM.
EINVAL advice is MADV_FREE or MADV_WIPEONFORK but the specified address
range includes file, Huge TLB, MAP_SHARED, or VM_PFNMAP ranges.