]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: retype mheap.pagesSweptBasis as atomic.Uint64
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 18 Oct 2021 23:10:43 +0000 (23:10 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 20 Oct 2021 20:39:29 +0000 (20:39 +0000)
[git-generate]
cd src/runtime
mv export_test.go export.go
GOROOT=$(dirname $(dirname $PWD)) rf '
  add mheap.pagesSweptBasis pagesSweptBasis_ atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio
  ex {
    import "runtime/internal/atomic"

    var t mheap
    var v, w uint64
    var d int64

    t.pagesSweptBasis -> t.pagesSweptBasis_.Load()
    t.pagesSweptBasis = v -> t.pagesSweptBasis_.Store(v)
    atomic.Load64(&t.pagesSweptBasis) -> t.pagesSweptBasis_.Load()
    atomic.LoadAcq64(&t.pagesSweptBasis) -> t.pagesSweptBasis_.LoadAcquire()
    atomic.Store64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.Store(v)
    atomic.StoreRel64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.StoreRelease(v)
    atomic.Cas64(&t.pagesSweptBasis, v, w) -> t.pagesSweptBasis_.CompareAndSwap(v, w)
    atomic.Xchg64(&t.pagesSweptBasis, v) -> t.pagesSweptBasis_.Swap(v)
    atomic.Xadd64(&t.pagesSweptBasis, d) -> t.pagesSweptBasis_.Add(d)
  }
  rm mheap.pagesSweptBasis
  mv mheap.pagesSweptBasis_ mheap.pagesSweptBasis
'
mv export.go export_test.go

Change-Id: Id9438184b9bd06d96894c02376385bad45dee154
Reviewed-on: https://go-review.googlesource.com/c/go/+/356710
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

src/runtime/mgcpacer.go
src/runtime/mgcsweep.go
src/runtime/mheap.go

index f858ab08d0896f79deadd7f7ec5927a3c9e7b25d..55f3bc926d8bc85d089e5db785ddea1a6703445d 100644 (file)
@@ -762,7 +762,7 @@ func (c *gcControllerState) commit(triggerRatio float64) {
                        // Write pagesSweptBasis last, since this
                        // signals concurrent sweeps to recompute
                        // their debt.
-                       atomic.Store64(&mheap_.pagesSweptBasis, pagesSwept)
+                       mheap_.pagesSweptBasis.Store(pagesSwept)
                }
        }
 
index 78d1f339250e977f1c405ab14e59f41943d3a5fa..aedd6c316e2e32c66a328db240530c3fd32f2acc 100644 (file)
@@ -719,7 +719,7 @@ func deductSweepCredit(spanBytes uintptr, callerSweepPages uintptr) {
        }
 
 retry:
-       sweptBasis := atomic.Load64(&mheap_.pagesSweptBasis)
+       sweptBasis := mheap_.pagesSweptBasis.Load()
 
        // Fix debt if necessary.
        newHeapLive := uintptr(atomic.Load64(&gcController.heapLive)-mheap_.sweepHeapLiveBasis) + spanBytes
@@ -729,7 +729,7 @@ retry:
                        mheap_.sweepPagesPerByte = 0
                        break
                }
-               if atomic.Load64(&mheap_.pagesSweptBasis) != sweptBasis {
+               if mheap_.pagesSweptBasis.Load() != sweptBasis {
                        // Sweep pacing changed. Recompute debt.
                        goto retry
                }
index 27f60771eb658a6b460eaafc23cfe0587d89fe4e..90e55315a609c27fe4babf0533347b48817a3cae 100644 (file)
@@ -104,7 +104,7 @@ type mheap struct {
        // progress has already been made.
        pagesInUse         atomic.Uint64 // pages of spans in stats mSpanInUse
        pagesSwept         atomic.Uint64 // pages swept this cycle
-       pagesSweptBasis    uint64        // pagesSwept to use as the origin of the sweep ratio; updated atomically
+       pagesSweptBasis    atomic.Uint64 // pagesSwept to use as the origin of the sweep ratio
        sweepHeapLiveBasis uint64        // value of gcController.heapLive to use as the origin of sweep ratio; written with lock, read without
        sweepPagesPerByte  float64       // proportional sweep ratio; written with lock, read without
        // TODO(austin): pagesInUse should be a uintptr, but the 386