diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2022-05-03 19:28:25 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-05-03 19:58:15 +0000 |
| commit | 7c404d59db3591a7c5854b38dc0f05fcb7ac0cff (patch) | |
| tree | c53ce941c2e4672bffa7116530cea819260dca7f /src/runtime/mgcsweep.go | |
| parent | bccce9028996502e62a92255d79d5e003fbae63b (diff) | |
| download | go-7c404d59db3591a7c5854b38dc0f05fcb7ac0cff.tar.xz | |
runtime: store consistent total allocation stats as uint64
Currently the consistent total allocation stats are managed as uintptrs,
which means they can easily overflow on 32-bit systems. Fix this by
storing these stats as uint64s. This will cause some minor performance
degradation on 32-bit systems, but there really isn't a way around this,
and it affects the correctness of the metrics we export.
Fixes #52680.
Change-Id: I7e6ca44047d46b4bd91c6f87c2d29f730e0d6191
Reviewed-on: https://go-review.googlesource.com/c/go/+/403758
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/mgcsweep.go')
| -rw-r--r-- | src/runtime/mgcsweep.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 698b7bff31..de57f18c4f 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -668,7 +668,7 @@ func (sl *sweepLocked) sweep(preserve bool) bool { // free slots zeroed. s.needzero = 1 stats := memstats.heapStats.acquire() - atomic.Xadduintptr(&stats.smallFreeCount[spc.sizeclass()], uintptr(nfreed)) + atomic.Xadd64(&stats.smallFreeCount[spc.sizeclass()], int64(nfreed)) memstats.heapStats.release() // Count the frees in the inconsistent, internal stats. @@ -720,8 +720,8 @@ func (sl *sweepLocked) sweep(preserve bool) bool { // Count the free in the consistent, external stats. stats := memstats.heapStats.acquire() - atomic.Xadduintptr(&stats.largeFreeCount, 1) - atomic.Xadduintptr(&stats.largeFree, size) + atomic.Xadd64(&stats.largeFreeCount, 1) + atomic.Xadd64(&stats.largeFree, int64(size)) memstats.heapStats.release() // Count the free in the inconsistent, internal stats. |
