From: Michael Anthony Knyszek Date: Fri, 29 Oct 2021 22:42:50 +0000 (+0000) Subject: runtime: disable pacer lock held assertions in tests X-Git-Tag: go1.18beta1~641 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b5a5b7bfb1ba25abf8cad8b9ad9451fb6e79d941;p=gostls13.git 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 Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 2cc89e7121..533627fa58 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -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 } 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 {