diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2019-12-01 14:18:14 -0500 |
|---|---|---|
| committer | Ben Gamari <ben@well-typed.com> | 2020-12-01 12:48:54 -0500 |
| commit | 84cf7ed6cde69b8e677c465628647ac902bbc23f (patch) | |
| tree | 191ffa3cc9a4db2d738447339376a3aa1e10331c | |
| parent | c6855d59cebda52424be0257e24bfe20c6eead56 (diff) | |
| download | haskell-84cf7ed6cde69b8e677c465628647ac902bbc23f.tar.gz | |
rts/Storage: Accept races on heap size counters
| -rw-r--r-- | rts/sm/Storage.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 7dd0ae98dd..86a111fca8 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -984,8 +984,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; } @@ -1463,10 +1463,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; |
