Commit 83ac5594 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

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.
parent 3d15d8d0
......@@ -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",
......@@ -1055,7 +1055,7 @@ new_gc_thread (uint32_t n, gc_thread *t)
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
......@@ -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;
debugTrace(DEBUG_gc, "GC thread %d standing by...", gct->thread_index);
......@@ -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
uint32_t thread_index; // a zero based index identifying the thread
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment