summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-01-01 20:56:02 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-09 21:21:37 -0500
commit83ac5594d101440f72dc0ead97f0d1583056c07d (patch)
treeeefd71c530bab1cd245c13dadf9bffd6dbc13729
parent3d15d8d008307a19314c23eeb65b8ead448f0b37 (diff)
downloadhaskell-83ac5594d101440f72dc0ead97f0d1583056c07d.tar.gz
rts: Use SEQ_CST accesses when touching `wakeup`
These are the two remaining non-atomic accesses to `wakeup` which were missed by the original TSAN patch.
-rw-r--r--rts/hooks/LongGCSync.c2
-rw-r--r--rts/sm/GC.c4
-rw-r--r--rts/sm/GCThread.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/rts/hooks/LongGCSync.c b/rts/hooks/LongGCSync.c
index 351406df98..58ee52fa3d 100644
--- a/rts/hooks/LongGCSync.c
+++ b/rts/hooks/LongGCSync.c
@@ -21,7 +21,7 @@ void LongGCSync (uint32_t me USED_IF_THREADS, Time t STG_UNUSED)
{
uint32_t i;
for (i=0; i < n_capabilities; i++) {
- if (i != me && gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) {
+ if (i != me && SEQ_CST_LOAD(&gc_threads[i]->wakeup) == GC_THREAD_STANDING_BY) {
debugBelch("Warning: slow GC sync: still waiting for cap %d\n",
i);
}
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index d8ce3a1377..4c46e82200 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -1055,7 +1055,7 @@ new_gc_thread (uint32_t n, gc_thread *t)
initSpinLock(&t->mut_spin);
ACQUIRE_SPIN_LOCK(&t->gc_spin);
ACQUIRE_SPIN_LOCK(&t->mut_spin);
- t->wakeup = GC_THREAD_INACTIVE; // starts true, so we can wait for the
+ SEQ_CST_STORE(&t->wakeup, GC_THREAD_INACTIVE); // starts true, so we can wait for the
// thread to start up, see wakeup_gc_threads
#endif
@@ -1300,7 +1300,7 @@ gcWorkerThread (Capability *cap)
// measurements more accurate on Linux, perhaps because it syncs
// the CPU time across the multiple cores. Without this, CPU time
// is heavily skewed towards GC rather than MUT.
- gct->wakeup = GC_THREAD_STANDING_BY;
+ SEQ_CST_STORE(&gct->wakeup, GC_THREAD_STANDING_BY);
debugTrace(DEBUG_gc, "GC thread %d standing by...", gct->thread_index);
ACQUIRE_SPIN_LOCK(&gct->gc_spin);
diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h
index 723bb00bf1..d15189988d 100644
--- a/rts/sm/GCThread.h
+++ b/rts/sm/GCThread.h
@@ -127,7 +127,7 @@ typedef struct gc_thread_ {
OSThreadId id; // The OS thread that this struct belongs to
SpinLock gc_spin;
SpinLock mut_spin;
- volatile StgWord wakeup; // NB not StgWord8; only StgWord is guaranteed atomic
+ StgWord wakeup; // This should only be accessed via atomic accesses
#endif
uint32_t thread_index; // a zero based index identifying the thread