summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-12-01 14:18:14 -0500
committerBen Gamari <ben@smart-cactus.org>2020-11-08 09:41:41 -0500
commitbd0fb1d247168829227627a766ba6a8ee8b6bcad (patch)
tree2bf2ea3dd03c906838cf13a20b7c90002ff1b0b5
parentbaa322e4e58bb7c28d45b87317aca69af02745b2 (diff)
downloadhaskell-bd0fb1d247168829227627a766ba6a8ee8b6bcad.tar.gz
rts/Storage: Accept races on heap size counters
-rw-r--r--rts/sm/Storage.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index 28d8c04fd4..251353de6d 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -1032,8 +1032,8 @@ allocateMightFail (Capability *cap, W_ n)
g0->n_new_large_words += n;
RELEASE_SM_LOCK;
initBdescr(bd, g0, g0);
- bd->flags = BF_LARGE;
- bd->free = bd->start + n;
+ RELAXED_STORE(&bd->flags, BF_LARGE);
+ RELAXED_STORE(&bd->free, bd->start + n);
cap->total_allocated += n;
return bd->start;
}
@@ -1561,10 +1561,13 @@ calcNeeded (bool force_major, memcount *blocks_needed)
for (uint32_t g = 0; g < RtsFlags.GcFlags.generations; g++) {
generation *gen = &generations[g];
-
W_ blocks = gen->live_estimate ? (gen->live_estimate / BLOCK_SIZE_W) : gen->n_blocks;
- blocks += gen->n_large_blocks
- + gen->n_compact_blocks;
+
+ // This can race with allocate() and compactAllocateBlockInternal()
+ // but only needs to be approximate
+ TSAN_ANNOTATE_BENIGN_RACE(&gen->n_large_blocks, "n_large_blocks");
+ blocks += RELAXED_LOAD(&gen->n_large_blocks)
+ + RELAXED_LOAD(&gen->n_compact_blocks);
// we need at least this much space
needed += blocks;