[Git][ghc/ghc][wip/T22264] 52 commits: rts: Encapsulate sched_state

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Dec 6 12:57:06 UTC 2022



Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC


Commits:
16a95a38 by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Encapsulate sched_state

- - - - -
6a4fd558 by Ben Gamari at 2022-12-06T07:56:28-05:00
PrimOps: Fix benign MutVar race

Relaxed ordering is fine here since the later CAS implies a release.

- - - - -
149a91be by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Style fix

- - - - -
c5b78290 by Ben Gamari at 2022-12-06T07:56:28-05:00
compiler: Use release store in eager blackholing

- - - - -
ab656ae7 by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Fix ordering of makeStableName

- - - - -
93265cc3 by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Use ordered accesses instead of explicit barriers

- - - - -
a6ca5913 by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Statically allocate capabilities

This is a rather simplistic way of solving #17289.

- - - - -
60ffe15f by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Ensure that all accesses to pending_sync are atomic

- - - - -
5e565a67 by Ben Gamari at 2022-12-06T07:56:28-05:00
rts: Note race with wakeBlockingQueue

- - - - -
1e04cf59 by Ben Gamari at 2022-12-06T07:56:28-05:00
nonmoving: Fix race in marking of blackholes

We must use an acquire-fence when marking to ensure that the indirectee
is visible.

- - - - -
2f938591 by Ben Gamari at 2022-12-06T07:56:28-05:00
nonmoving: Fix segment list races

- - - - -
2726d722 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Use atomic when looking at bd->gen

Since it may have been mutated by a moving GC.

- - - - -
d3cd49cf by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Eliminate race in bump_static_flag

To ensure that we don't race with a mutator entering a new CAF we take
the SM mutex before touching static_flag. The other option here would be
to instead modify newCAF to use a CAS but the present approach is a bit
safer.

- - - - -
6f52b643 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Ensure that mutable fields have acquire barrier

- - - - -
947feeab by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Fix races in collector status tracking

Mark a number of accesses to do with tracking of the status of the
concurrent collection thread as atomic. No interesting races here,
merely necessary to satisfy TSAN.

- - - - -
5b09ee54 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Make segment state updates atomic

- - - - -
651f6f3f by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Refactor update remembered set initialization

This avoids a lock inversion between the storage manager mutex and
the stable pointer table mutex by not dropping the SM_MUTEX in
nonmovingCollect. This requires quite a bit of rejiggering but it
does seem like a better strategy.

- - - - -
b2b2008f by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Ensure that we aren't holding locks when closing them

TSAN complains about this sort of thing.

- - - - -
c868eee0 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Make bitmap accesses atomic

This is a benign race on any sensible hard since these are byte
accesses. Nevertheless, atomic accesses are necessary to satisfy
TSAN.

- - - - -
87e3d20d by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Fix benign race in update remembered set check

Relaxed load is fine here since we will take the lock before looking at
the list.

- - - - -
a5b1d1d2 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Fix race in shortcutting

We must use an acquire load to read the info table pointer since if we
find an indirection we must be certain that we see the indirectee.

- - - - -
e090f105 by Ben Gamari at 2022-12-06T07:56:29-05:00
nonmoving: Make free list counter accesses atomic

Since these may race with the allocator(s).

- - - - -
a98caae0 by Ben Gamari at 2022-12-06T07:57:00-05:00
nonmoving: Fix style

- - - - -
00be5445 by Ben Gamari at 2022-12-06T07:57:00-05:00
nonmoving: Deduplicate assertion

- - - - -
f2f4fa99 by Ben Gamari at 2022-12-06T07:57:00-05:00
rts: Fix type issues in Sparks.h

Adds explicit casts to satisfy a C++ compiler.

- - - - -
87c435f8 by Ben Gamari at 2022-12-06T07:57:00-05:00
rts/BlockAlloc: Allow disabling of internal assertions

These can be quite expensive and it is sometimes useful to compile a
DEBUG RTS without them.

- - - - -
c46b2526 by Ben Gamari at 2022-12-06T07:57:00-05:00
rts/Sanity: Mark pinned_object_blocks

- - - - -
c15aa019 by Ben Gamari at 2022-12-06T07:57:00-05:00
rts/Sanity: Look at nonmoving saved_filled lists

- - - - -
fcb8cd27 by Ben Gamari at 2022-12-06T07:57:01-05:00
Evac: Squash data race in eval_selector_chain

- - - - -
b9ec577d by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Clarify implementation

This makes the intent of this implementation a bit clearer.

- - - - -
4993b652 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Clarify comment

- - - - -
671418f9 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Add missing no-op in busy-wait loop

- - - - -
2d1798bc by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Don't push empty arrays to update remembered set

Previously the write barrier of resizeSmallArray# incorrectly handled
resizing of zero-sized arrays, pushing an invalid pointer to the update
remembered set.

Likely fixes the cause of #22264.

- - - - -
90849796 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Fix handling of weak pointers

This fixes an interaction between aging and weak pointer handling which
prevented the finalization of some weak pointers. In particular, weak
pointers could have their keys incorrectly marked by the preparatory
collector, preventing their finalization by the subsequent concurrent
collection.

While in the area, we also significantly improve the assertions
regarding weak pointers.

Fixes #22327.

- - - - -
aa8f7211 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Sanity check nonmoving large objects and compacts

- - - - -
4f251f3c by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Sanity check mutable list

Assert that entries in the nonmoving generation's generational
remembered set (a.k.a. mutable list) live in nonmoving generation.

- - - - -
37c51b8a by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Don't show occupancy if we didn't collect live words

- - - - -
6fded74b by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Fix tracking of FILLED_SWEEPING segments

Previously we only updated the state of the segment at the head of each
allocator's filled list.

- - - - -
4c526846 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Assert state of swept segments

- - - - -
fa93fda5 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Handle new closures in nonmovingIsNowAlive

- - - - -
72224150 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Don't clobber update rem sets of old capabilities

Previously `storageAddCapabilities` (called by `setNumCapabilities`) would
clobber the update remembered sets of existing capabilities when
increasing the capability count. Fix this by only initializing the
update remembered sets of the newly-created capabilities.

- - - - -
25a7ecdc by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Add missing write barriers in selector optimisation

This fixes the selector optimisation, adding a few write barriers which
are necessary for soundness.

- - - - -
7337c60c by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Post-sweep sanity checking

- - - - -
7fee5d4d by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Avoid n_caps race

- - - - -
8adc1750 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Don't push if nonmoving collector isn't enabled

- - - - -
2459eb8c by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Paranoia

- - - - -
1a1778e6 by Ben Gamari at 2022-12-06T07:57:01-05:00
rts: Drop racy assertion

0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
`dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
However, this isn't necessarily the case since another thread may have
raced us to dirty the object.

- - - - -
ebca3b8b by Ben Gamari at 2022-12-06T07:57:01-05:00
rts: Drop SM spinlock

- - - - -
81a24c88 by Ben Gamari at 2022-12-06T07:57:01-05:00
rts: C++ typing issues

Make the RTS compilable with a C++ compiler by inserting necessary
casts.

- - - - -
52beb656 by Ben Gamari at 2022-12-06T07:57:01-05:00
setNumCapabilities

- - - - -
f29140a9 by Ben Gamari at 2022-12-06T07:57:01-05:00
nonmoving: Disable shortcutting

- - - - -
4a91acb1 by Ben Gamari at 2022-12-06T07:57:01-05:00
CheckGC

- - - - -


30 changed files:

- compiler/GHC/StgToCmm/Bind.hs
- libraries/base/GHC/Conc/Sync.hs
- rts/Capability.c
- rts/Capability.h
- rts/CheckUnload.c
- rts/PrimOps.cmm
- rts/RtsStartup.c
- rts/Schedule.c
- rts/Schedule.h
- rts/Sparks.h
- rts/Stats.c
- rts/StgMiscClosures.cmm
- rts/Trace.h
- rts/eventlog/EventLog.c
- rts/include/Cmm.h
- rts/include/rts/Config.h
- rts/include/rts/Threads.h
- rts/include/rts/storage/ClosureMacros.h
- rts/include/rts/storage/MBlock.h
- rts/include/stg/SMP.h
- rts/posix/Select.c
- rts/posix/Signals.c
- rts/rts.cabal.in
- rts/sm/BlockAlloc.c
- + rts/sm/CheckGc.cpp
- rts/sm/Evac.c
- rts/sm/GC.c
- rts/sm/GC.h
- rts/sm/GCUtils.c
- rts/sm/GCUtils.h


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22cd7bb71e1565a48c43d38fe044c517d0aa1d30...4a91acb13ad757f710c3cbcd35d29c06176cdef0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22cd7bb71e1565a48c43d38fe044c517d0aa1d30...4a91acb13ad757f710c3cbcd35d29c06176cdef0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221206/f55baf86/attachment-0001.html>


More information about the ghc-commits mailing list