summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-27 18:52:15 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:37 -0400
commit8d2b3c3d1fcb9009b6dfcce85777e04bcec9d219 (patch)
tree21abdb46f64f1608d983a89dd7643d2431513212
parent811f915db3b682f33aad2c3e6ca039a6e8451c69 (diff)
downloadhaskell-8d2b3c3d1fcb9009b6dfcce85777e04bcec9d219.tar.gz
rts: Eliminate data races on pending_sync
-rw-r--r--rts/Capability.c4
-rw-r--r--rts/Schedule.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/rts/Capability.c b/rts/Capability.c
index 0b5f009800..5ebe6c8b46 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -544,7 +544,7 @@ releaseCapability_ (Capability* cap,
// be currently in waitForCapability() waiting for this
// capability, in which case simply setting it as free would not
// wake up the waiting task.
- PendingSync *sync = pending_sync;
+ PendingSync *sync = SEQ_CST_LOAD(&pending_sync);
if (sync && (sync->type != SYNC_GC_PAR || sync->idle[cap->no])) {
debugTrace(DEBUG_sched, "sync pending, freeing capability %d", cap->no);
return;
@@ -906,7 +906,7 @@ yieldCapability (Capability** pCap, Task *task, bool gcAllowed)
if (gcAllowed)
{
- PendingSync *sync = pending_sync;
+ PendingSync *sync = SEQ_CST_LOAD(&pending_sync);
if (sync) {
switch (sync->type) {
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 5568d9c99e..a9ae7a4ce4 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -657,7 +657,7 @@ shouldYieldCapability (Capability *cap, Task *task, bool didGcLast)
// We would usually need to hold cap->lock to look at n_returning_tasks but
// we don't here since this is just an approximate predicate.
TSAN_ANNOTATE_BENIGN_RACE(&cap->n_returning_tasks, "shouldYieldCapability");
- return ((pending_sync && !didGcLast) ||
+ return ((RELAXED_LOAD(&pending_sync) && !didGcLast) ||
RELAXED_LOAD(&cap->n_returning_tasks) != 0 ||
(!emptyRunQueue(cap) && (task->incall->tso == NULL
? peekRunQueue(cap)->bound != NULL
@@ -1491,7 +1491,7 @@ static bool requestSync (
sync->type);
ASSERT(*pcap);
yieldCapability(pcap,task,true);
- sync = pending_sync;
+ sync = SEQ_CST_LOAD(&pending_sync);
} while (sync != NULL);
}
@@ -1522,7 +1522,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task)
Capability *tmpcap;
uint32_t i;
- ASSERT(pending_sync != NULL);
+ ASSERT(SEQ_CST_LOAD(&pending_sync) != NULL);
for (i=0; i < n_capabilities; i++) {
debugTrace(DEBUG_sched, "grabbing all the capabilies (%d/%d)",
i, n_capabilities);