diff options
author | Ben Gamari <ben@smart-cactus.org> | 2023-04-27 07:45:13 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2023-04-27 08:39:32 -0400 |
commit | 5bfbff20d9c867a50299c3ffd2b07da510cce31a (patch) | |
tree | a20eac6d88ce4b036ff598e3176e518d69948286 | |
parent | ebd5b0781c6e6f4642db91353fab0f0ec04af3bc (diff) | |
download | haskell-wip/T23312.tar.gz |
nonmoving: Account for mutator allocations in bytes_allocatedwip/T23312
Previously we failed to account direct mutator allocations into the
nonmoving heap against the mutator's allocation limit and
`cap->total_allocated`. This only manifests during CAF evaluation (since
we allocate the CAF's blackhole directly into the nonmoving heap).
Fixes #23312.
-rw-r--r-- | rts/sm/NonMovingAllocate.c | 4 | ||||
-rw-r--r-- | rts/sm/Storage.c | 2 | ||||
-rw-r--r-- | rts/sm/Storage.h | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/rts/sm/NonMovingAllocate.c b/rts/sm/NonMovingAllocate.c index c826a0ff3a..f6d2621f23 100644 --- a/rts/sm/NonMovingAllocate.c +++ b/rts/sm/NonMovingAllocate.c @@ -253,5 +253,9 @@ void *nonmovingAllocateGC(Capability *cap, StgWord sz) GNUC_ATTR_HOT void *nonmovingAllocate(Capability *cap, StgWord sz) { + // Handle "bytes allocated" accounting in the same way we + // do in Storage.c:allocate. See #23312. + accountAllocation(cap, sz); + cap->total_allocated += sz; return nonmovingAllocate_(SM_LOCK, cap, sz); } diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 6d6500df9a..ec2f446a3f 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -966,7 +966,7 @@ move_STACK (StgStack *src, StgStack *dest) dest->sp = (StgPtr)dest->sp + diff; } -STATIC_INLINE void +void accountAllocation(Capability *cap, W_ n) { TICK_ALLOC_HEAP_NOCTR(WDS(n)); diff --git a/rts/sm/Storage.h b/rts/sm/Storage.h index 42c56fe164..a0d9af8de6 100644 --- a/rts/sm/Storage.h +++ b/rts/sm/Storage.h @@ -125,6 +125,8 @@ StgWord genLiveBlocks (generation *gen); StgWord calcTotalLargeObjectsW (void); StgWord calcTotalCompactW (void); +void accountAllocation(Capability *cap, W_ n); + /* ---------------------------------------------------------------------------- Storage manager internal APIs and globals ------------------------------------------------------------------------- */ |