aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgcpacer.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-10-29 22:42:50 +0000
committerMichael Knyszek <mknyszek@google.com>2021-11-01 18:53:06 +0000
commitb5a5b7bfb1ba25abf8cad8b9ad9451fb6e79d941 (patch)
tree73a5545d30e13201f5a8dd8e3bc4409d075d1aaf /src/runtime/mgcpacer.go
parent2bcf1c0373195724161a9dc287e1dbc26404e4fa (diff)
downloadgo-b5a5b7bfb1ba25abf8cad8b9ad9451fb6e79d941.tar.gz
go-b5a5b7bfb1ba25abf8cad8b9ad9451fb6e79d941.zip
runtime: disable pacer lock held assertions in tests
Fixes #49234. Change-Id: I64c1eab0dce2bbe990343b43a32858a6c9f3dcda Reviewed-on: https://go-review.googlesource.com/c/go/+/359878 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mgcpacer.go')
-rw-r--r--src/runtime/mgcpacer.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go
index 160383db43..af43e6258f 100644
--- a/src/runtime/mgcpacer.go
+++ b/src/runtime/mgcpacer.go
@@ -269,6 +269,9 @@ type gcControllerState struct {
// If this is zero, no fractional workers are needed.
fractionalUtilizationGoal float64
+ // test indicates that this is a test-only copy of gcControllerState.
+ test bool
+
_ cpu.CacheLinePad
}
@@ -737,7 +740,9 @@ func (c *gcControllerState) addGlobals(amount int64) {
//
// mheap_.lock must be held or the world must be stopped.
func (c *gcControllerState) commit(triggerRatio float64) {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
// Compute the next GC goal, which is when the allocated heap
// has grown by GOGC/100 over the heap marked by the last
@@ -842,7 +847,9 @@ func (c *gcControllerState) commit(triggerRatio float64) {
//
// mheap_.lock must be held or the world must be stopped.
func (c *gcControllerState) effectiveGrowthRatio() float64 {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
egogc := float64(atomic.Load64(&c.heapGoal)-c.heapMarked) / float64(c.heapMarked)
if egogc < 0 {
@@ -859,7 +866,9 @@ func (c *gcControllerState) effectiveGrowthRatio() float64 {
//
// The world must be stopped, or mheap_.lock must be held.
func (c *gcControllerState) setGCPercent(in int32) int32 {
- assertWorldStoppedOrLockHeld(&mheap_.lock)
+ if !c.test {
+ assertWorldStoppedOrLockHeld(&mheap_.lock)
+ }
out := c.gcPercent
if in < 0 {