[Git][ghc/ghc][wip/tsan/all] 2 commits: Annotate hopefully "benign" race in freeGroup
Ben Gamari
gitlab at gitlab.haskell.org
Sat Oct 31 05:13:38 UTC 2020
Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC
Commits:
1050e8d8 by Ben Gamari at 2020-10-31T01:12:46-04:00
Annotate hopefully "benign" race in freeGroup
- - - - -
098c1f93 by Ben Gamari at 2020-10-31T01:13:13-04:00
Strengthen ordering in releaseGCThreads
- - - - -
2 changed files:
- rts/sm/BlockAlloc.c
- rts/sm/GC.c
Changes:
=====================================
rts/sm/BlockAlloc.c
=====================================
@@ -856,6 +856,12 @@ freeGroup(bdescr *p)
prev = p - 1;
if (prev->blocks == 0) prev = prev->link; // find the head
+ // This is a bit hairy... we are looking at bd->free of a block that we
+ // do not own and yet have not synchronized with the thread that *does*
+ // own the block. We currently assume we won't see torn values and
+ // consequently this will work, although this is strictly speaking not
+ // guaranteed under the memory model.
+ TSAN_ANNOTATE_BENIGN_RACE(&prev->free, "freeGroup");
if (RELAXED_LOAD(&prev->free) == (P_)-1)
{
ln = log_2(prev->blocks);
=====================================
rts/sm/GC.c
=====================================
@@ -1416,10 +1416,10 @@ releaseGCThreads (Capability *cap USED_IF_THREADS, bool idle_cap[])
uint32_t i;
for (i=0; i < n_threads; i++) {
if (i == me || idle_cap[i]) continue;
- if (RELAXED_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE)
+ if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE)
barf("releaseGCThreads");
- RELAXED_STORE(&gc_threads[i]->wakeup, GC_THREAD_INACTIVE);
+ SEQ_CST_STORE(&gc_threads[i]->wakeup, GC_THREAD_INACTIVE);
ACQUIRE_SPIN_LOCK(&gc_threads[i]->gc_spin);
RELEASE_SPIN_LOCK(&gc_threads[i]->mut_spin);
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8be6fdee5377d4fcd7eacd935b2644461c6e2bb...098c1f934c079cba390f4e51d83b744eaec12666
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8be6fdee5377d4fcd7eacd935b2644461c6e2bb...098c1f934c079cba390f4e51d83b744eaec12666
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/20201031/bf120198/attachment-0001.html>
More information about the ghc-commits
mailing list