]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: disable pacer lock held assertions in tests
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 29 Oct 2021 22:42:50 +0000 (22:42 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 1 Nov 2021 18:53:06 +0000 (18:53 +0000)
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>
src/runtime/export_test.go
src/runtime/mgcpacer.go

index 2cc89e71218fa06bff4373c6b62d0186cc537044..533627fa585f374a32ee24b8487202a046b4f8bf 100644 (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
 }
index 160383db43712dfe1451b7a5b6ddcff8dff274c5..af43e6258f2700716d70848a5337e303b7830180 100644 (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) {
-       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 {