summaryrefslogtreecommitdiff
path: root/rts/sm/Storage.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2013-09-04 10:37:10 +0100
committerSimon Marlow <marlowsd@gmail.com>2013-09-04 11:00:32 +0100
commitaa779e092c4f4d6a6691f3a4fc4074e6359337f8 (patch)
treef4c4e22da3aa71eff569b01af603836d7b5fd6a5 /rts/sm/Storage.c
parent5a3918febb7354e0900c4f04151599d833716032 (diff)
downloadhaskell-aa779e092c4f4d6a6691f3a4fc4074e6359337f8.tar.gz
Don't move Capabilities in setNumCapabilities (#8209)
We have various problems with reallocating the array of Capabilities, due to threads in waitForReturnCapability that are already holding a pointer to a Capability. Rather than add more locking to make this safer, I decided it would be easier to ensure that we never move the Capabilities at all. The capabilities array is now an array of pointers to Capabaility. There are extra indirections, but it rarely matters - we don't often access Capabilities via the array, normally we already have a pointer to one. I ran the parallel benchmarks and didn't see any difference.
Diffstat (limited to 'rts/sm/Storage.c')
-rw-r--r--rts/sm/Storage.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index a5337bc5b2..b575fc3e52 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -215,7 +215,7 @@ void storageAddCapabilities (nat from, nat to)
// we've moved the nurseries, so we have to update the rNursery
// pointers from the Capabilities.
for (i = 0; i < to; i++) {
- capabilities[i].r.rNursery = &nurseries[i];
+ capabilities[i]->r.rNursery = &nurseries[i];
}
/* The allocation area. Policy: keep the allocation area
@@ -229,7 +229,7 @@ void storageAddCapabilities (nat from, nat to)
// allocate a block for each mut list
for (n = from; n < to; n++) {
for (g = 1; g < RtsFlags.GcFlags.generations; g++) {
- capabilities[n].mut_lists[g] = allocBlock();
+ capabilities[n]->mut_lists[g] = allocBlock();
}
}
@@ -493,8 +493,8 @@ assignNurseriesToCapabilities (nat from, nat to)
nat i;
for (i = from; i < to; i++) {
- capabilities[i].r.rCurrentNursery = nurseries[i].blocks;
- capabilities[i].r.rCurrentAlloc = NULL;
+ capabilities[i]->r.rCurrentNursery = nurseries[i].blocks;
+ capabilities[i]->r.rCurrentAlloc = NULL;
}
}
@@ -939,7 +939,7 @@ void updateNurseriesStats (void)
nat i;
for (i = 0; i < n_capabilities; i++) {
- capabilities[i].total_allocated += countOccupied(nurseries[i].blocks);
+ capabilities[i]->total_allocated += countOccupied(nurseries[i].blocks);
}
}