[GHC] #12865: POSIX osDecommitMemory has nasty compatibility problems
#12865: POSIX osDecommitMemory has nasty compatibility problems ----------------------------------------+--------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Keywords: | Operating System: Linux Architecture: Unknown/Multiple | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------------- `osDecommitMemory` in `rts/posix/OSMem.c` currently does the following, {{{#!c #ifdef MADV_FREE // Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED // just swaps memory out r = madvise(at, size, MADV_FREE); #else r = madvise(at, size, MADV_DONTNEED); #endif if(r < 0) sysErrorBelch("unable to decommit memory"); }}} As it turns out, the Linux kernel as of 4.5 supports `MADV_FREE`. This means that binary distributions built in such environments will use `MADV_FREE`, even if running on an older kernel that does not support this advice. Ultimately this means that any attempt to decommit will fail. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12865> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12865: POSIX osDecommitMemory has nasty compatibility problems -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): One approach to fixing this would be to instead do something like this, {{{#!c int r = 1; #ifdef MADV_FREE // Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED // just swaps memory out r = madvise(at, size, MADV_FREE); #endif #ifdef MADV_DONTNEED if (r != 0) r = madvise(at, size, MADV_DONTNEED); #endif if(r < 0) sysErrorBelch("unable to decommit memory"); }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12865#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12865: POSIX osDecommitMemory has nasty compatibility problems -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2780 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D2780 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12865#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12865: POSIX osDecommitMemory has nasty compatibility problems -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2780 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"6576bf83cdf4eac05eb88a24aa934a736c91e3da/ghc" 6576bf83/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="6576bf83cdf4eac05eb88a24aa934a736c91e3da" rts: Ensure we always give MADV_DONTNEED a chance in osDecommitMemory As described in #12865, newer Linux kernels support both MADV_FREE and MADV_DONTNEED. Previously a runtime would fail to try MADV_DONTNEED if MADV_FREE failed (e.g. since the kernel which the image is running on doesn't support the latter). Now we try MADV_DONTNEED if MADV_FREE failed to ensure that binaries compiled on a kernel supporting MADV_FREE don't fail on decommit. Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2780 GHC Trac Issues: #12865 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12865#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12865: POSIX osDecommitMemory has nasty compatibility problems -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2780 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12865#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC