summaryrefslogtreecommitdiff
path: root/includes
Commit message (Collapse)AuthorAgeFilesLines
* Move ioManager{Start,Wakeup,Die} to internal IOManager.hDuncan Coutts2021-01-251-12/+0
| | | | | | | | Move them from the external IOInterface.h to the internal IOManager.h. The functions are all in fact internal. They are not used from the base library at all. Remove ioManagerWakeup as an exported symbol. It is not used elsewhere.
* Rename includes/rts/IOManager.h to IOInterface.hDuncan Coutts2021-01-252-1/+1
| | | | | | | | | | | | | | | | | | | | | Naming is hard. Where we want to get to is to have a clear internal and external API for the IO manager within the RTS. What we have right now is just the external API (used in base for the Haskell side of the threaded IO manager impls) living in includes/rts/IOManager.h. We want to add a clear RTS internal API, which really ought to live in rts/IOManager.h. Several people think it's too confusing to have both: * includes/rts/IOManager.h for the external API * rts/IOManager.h for the internal API So the plan is to add rts/IOManager.{h,c} as the internal parts, and rename the external part to be includes/rts/IOInterface.h. It is admittidly not great to have .h files in includes/rts/ called "interface" since by definition, every .h fle under includes/ is an interface! Alternative naming scheme suggestions welcome!
* Force inlining of deRefStablePtr to silence warningsAndreas Klebinger2021-01-221-2/+2
|
* rts: Initialize card table in newArray#Ben Gamari2021-01-171-13/+20
| | | | | | | | | | Previously we would leave the card table of new arrays uninitialized. This wasn't a soundness issue: at worst we would end up doing unnecessary scavenging during GC, after which the card table would be reset. That being said, it seems worth initializing this properly to avoid both unnecessary work and non-determinism. Fixes #19143.
* rts: gc: use mutex+condvar instead of spinlooks in gc entry/exitDouglas Wilson2021-01-171-14/+0
| | | | | | used timed wait on condition variable in waitForGcThreads fix dodgy timespec calculation
* rts: add timedWaitConditionDouglas Wilson2021-01-171-0/+1
|
* rts: add max_n_todo_overflow internal counterDouglas Wilson2021-01-171-0/+2
| | | | | | | | I've never observed this counter taking a non-zero value, however I do think it's existence is justified by the comment in grab_local_todo_block. I've not added it to RTSStats in GHC.Stats, as it doesn't seem worth the api churn.
* rts: remove no_work counterDouglas Wilson2021-01-171-3/+0
| | | | We are no longer busyish waiting, so this is no longer meaningful
* rts/eventlog: Introduce event to demarcate new ticky sampleBen Gamari2021-01-171-1/+2
|
* rts: Zero shrunk array slop in vanilla RTSBen Gamari2021-01-071-1/+5
| | | | | | But only when profiling or DEBUG are enabled. Fixes #17572.
* rts: Use weaker cas in WSDequeDouglas Wilson2020-12-191-0/+24
| | | | | | | | The algorithm described in the referenced paper uses this slightly weaker atomic op. This is the first "exotic" cas we're using. I've added a macro in the <ORDERING>_OP style to match existing ones.
* ThreadPaused: Don't zero slop until free vars are pushedGHC GitLab CI2020-11-291-0/+4
| | | | | | | | When threadPaused blackholes a thunk it calls `OVERWRITING_CLOSURE` to zero the slop for the benefit of the sanity checker. Previously this was done *before* pushing the thunk's free variables to the update remembered set. Consequently we would pull zero'd pointers to the update remembered set.
* rts: Use RTS_LIKELY in CHECKBen Gamari2020-11-261-2/+2
| | | | | Most compilers probably already infer that `barf` diverges but it nevertheless doesn't hurt to be explicit.
* RTS: Fix failed inlining of copy_tag.Andreas Klebinger2020-11-261-1/+6
| | | | | | | | | | | | | | | On windows using gcc-10 gcc failed to inline copy_tag into evacuate. To fix this we now set the always_inline attribute for the various copy* functions in Evac.c. The main motivation here is not the overhead of the function call, but rather that this allows the code to "specialize" for the size of the closure we copy which is often known at compile time. An earlier commit also tried to avoid evacuate_large inlining. But didn't quite succeed. So I also marked evacuate_large as noinline. Fixes #12416
* rts: Flush eventlog buffers from flushEventLogBen Gamari2020-11-242-2/+8
| | | | | | | | | | | | As noted in #18043, flushTrace failed flush anything beyond the writer. This means that a significant amount of data sitting in capability-local event buffers may never get flushed, despite the users' pleads for us to flush. Fix this by making flushEventLog flush all of the event buffers before flushing the writer. Fixes #18043.
* rts: Post ticky entry counts to the eventlogBen Gamari2020-11-212-1/+5
| | | | | | | | We currently only post the entry counters, not the other global counters as in my experience the former are more useful. We use the heap profiler's census period to decide when to dump. Also spruces up the documentation surrounding ticky-ticky a bit.
* AArch64/arm64 adjustmentsMoritz Angermann2020-11-153-3/+4
| | | | | | | | This addes the necessary logic to support aarch64 on elf, as well as aarch64 on mach-o, which Apple calls arm64. We change architecture name to AArch64, which is the official arm naming scheme.
* Add rts_listThreads and rts_listMiscRoots to RtsAPI.hDavid Eichmann2020-11-131-0/+12
| | | | | | | | These are used to find the current roots of the garbage collector. Co-authored-by: Sven Tennie's avatarSven Tennie <sven.tennie@gmail.com> Co-authored-by: Matthew Pickering's avatarMatthew Pickering <matthewtpickering@gmail.com> Co-authored-by: default avatarBen Gamari <bgamari.foss@gmail.com>
* rts: Introduce highMemDynamicGHC GitLab CI2020-11-111-0/+4
|
* Add loadNativeObj and unloadNativeObjRay Shih2020-11-111-0/+13
| | | | | | | | | | | | | | | | | | | (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific.
* Add code comments for StgInfoTable and StgStack structsDavid Eichmann2020-11-102-2/+19
|
* ghc-heap: expose decoding from heap representationDavid Eichmann2020-11-101-0/+9
| | | | | | Co-authored-by: Sven Tennie <sven.tennie@gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com> Co-authored-by: Ben Gamari <bgamari.foss@gmail.com>
* Merge remote-tracking branch 'origin/wip/tsan/all'Ben Gamari2020-11-089-35/+186
|\
| * Merge branch 'wip/tsan/stm' into wip/tsan/allBen Gamari2020-11-011-3/+3
| |\
| | * rts/stm: Strengthen orderings to SEQ_CST instead of volatilewip/tsan/stmBen Gamari2020-10-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the `current_value`, `first_watch_queue_entry`, and `num_updates` fields of `StgTVar` were marked as `volatile` in an attempt to provide strong ordering. Of course, this isn't sufficient. We now use proper atomic operations. In most of these cases I strengthen the ordering all the way to SEQ_CST although it's possible that some could be weakened with some thought.
| * | Merge branch 'wip/tsan/wsdeque' into wip/tsan/allBen Gamari2020-11-011-0/+15
| |\ \
| | * | rts/WSDeque: Rewrite with proper atomicswip/tsan/wsdequeBen Gamari2020-10-241-0/+15
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a few attempts at shoring up the previous implementation, I ended up turning to the literature and now use the proven implementation, > N.M. LĂȘ, A. Pop, A.Cohen, and F.Z. Nardelli. "Correct and Efficient > Work-Stealing for Weak Memory Models". PPoPP'13, February 2013, > ACM 978-1-4503-1922/13/02. Note only is this approach formally proven correct under C11 semantics but it is also proved to be a bit faster in practice.
| * | Merge branch 'wip/tsan/storage' into wip/tsan/allBen Gamari2020-11-015-15/+16
| |\ \
| | * | rts: Use relaxed ordering on spinlock counterswip/tsan/storageBen Gamari2020-10-301-0/+2
| | | |
| | * | rts/SpinLock: Separate out slow pathBen Gamari2020-10-301-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`).
| | * | rts: Join to concurrent mark thread during shutdownBen Gamari2020-10-301-1/+2
| | | | | | | | | | | | | | | | | | | | Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread.
| | * | rts/GC: Use atomicsBen Gamari2020-10-301-3/+3
| | | |
| | * | rts: Avoid data races in StablePtr implementationBen Gamari2020-10-241-1/+5
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes two potentially problematic data races in the StablePtr implementation: * We would fail to RELEASE the stable pointer table when enlarging it, causing other cores to potentially see uninitialized memory. * We would fail to ACQUIRE when dereferencing a stable pointer.
| * | Merge branch 'wip/tsan/ci' into wip/tsan/allBen Gamari2020-11-011-0/+4
| |\ \
| | * | TSANUtils: Ensure that C11 atomics are supportedBen Gamari2020-10-241-0/+4
| | |/
| * | Capabiliity: Properly fix data race on n_returning_tasksBen Gamari2020-10-241-0/+1
| |/ | | | | | | | | There is a real data race but can be made safe by using proper atomic (but relaxed) accesses.
| * rts: Introduce SET_HDR_RELEASEwip/tsan/prepBen Gamari2020-10-241-2/+8
| | | | | | | | | | Also ensure that we also store the info table pointer last to ensure that the synchronization covers all stores.
| * rts/ClosureMaros: Use relaxed atomicsBen Gamari2020-10-241-10/+13
| |
| * rts/SpinLock: Move to proper atomicsBen Gamari2020-10-241-6/+4
| | | | | | | | | | | | This is fairly straightforward; we just needed to use relaxed operations for the PROF_SPIN counters and a release store instead of a write barrier.
| * rts: Infrastructure for testing with ThreadSanitizerBen Gamari2020-10-242-0/+64
| |
| * SMP.h: Add C11-style atomic operationsBen Gamari2020-10-241-1/+60
| |
* | [AArch64] Aarch64 Always PICMoritz Angermann2020-11-061-1/+1
| |
* | RtsAPI: pause and resume the RTSDavid Eichmann2020-11-022-8/+95
|/ | | | | | | | | The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie@gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com> Co-authored-by: Ben Gamari <bgamari.foss@gmail.com>
* Don't get host RTS ways via settings (#18651)Sylvain Henry2020-10-171-6/+0
| | | | | | | | | | | | To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file.
* When using rts_setInCallCapability, lock incall threadsDylan Yudaken2020-10-171-4/+4
| | | | | | | | This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability.
* Expose RTS-only ways (#18651)Sylvain Henry2020-10-091-0/+9
| | | | | Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself.
* rts: Fix integer width in TICK_BUMP_BYBen Gamari2020-10-051-1/+1
| | | | | | | | | | | | | | Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783.
* Remove unused global variablesSylvain Henry2020-09-301-4/+0
| | | | | | | | | | Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358
* Remove unsafeGlobalDynFlags (#17957, #14597)Sylvain Henry2020-09-301-1/+3
| | | | | There are still global variables but only 3 booleans instead of a single DynFlags.
* rts: Refactor unloading of foreign export StablePtrsBen Gamari2020-09-181-0/+2
| | | | | | Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups.