1
0
mirror of https://github.com/golang/go synced 2024-11-17 22:24:47 -07:00

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>
This commit is contained in:
Michael Anthony Knyszek 2021-10-29 22:42:50 +00:00 committed by Michael Knyszek
parent 2bcf1c0373
commit b5a5b7bfb1
2 changed files with 13 additions and 3 deletions

View File

@ -1246,6 +1246,7 @@ func NewGCController(gcPercent int) *GCController {
// on a 32-bit architecture, it may get allocated unaligned
// space.
g := escape(new(GCController)).(*GCController)
g.gcControllerState.test = true // Mark it as a test copy.
g.init(int32(gcPercent))
return g
}

View File

@ -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) {
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 {
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 {
if !c.test {
assertWorldStoppedOrLockHeld(&mheap_.lock)
}
out := c.gcPercent
if in < 0 {