]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert gcController.fractionalMarkTime to atomic type
authorMichael Pratt <mpratt@google.com>
Fri, 15 Jul 2022 20:47:03 +0000 (16:47 -0400)
committerMichael Pratt <mpratt@google.com>
Mon, 8 Aug 2022 14:12:03 +0000 (14:12 +0000)
For #53821.

Change-Id: Ic54bda422b87ee9365090fe6b42b82df7b25d2a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/417782
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/align_runtime_test.go
src/runtime/mgc.go
src/runtime/mgcpacer.go

index bca01e23e216dfef95f301fceabd4a22417e977b..98e1622e7a95ef38b68183b7a8c3cf818055b183 100644 (file)
@@ -22,7 +22,6 @@ var AtomicFields = []uintptr{
        unsafe.Offsetof(schedt{}.pollUntil),
        unsafe.Offsetof(schedt{}.timeToRun),
        unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
-       unsafe.Offsetof(gcControllerState{}.fractionalMarkTime),
        unsafe.Offsetof(gcControllerState{}.idleMarkTime),
        unsafe.Offsetof(timeHistogram{}.underflow),
        unsafe.Offsetof(profBuf{}.overflow),
index 06ea86929a14fd69ededf392c9afd1f014a1bb3b..01eee16a4d3fcd704f971ca19590ac9817fff9f2 100644 (file)
@@ -1009,7 +1009,7 @@ func gcMarkTermination() {
        sweepTermCpu := int64(work.stwprocs) * (work.tMark - work.tSweepTerm)
        // We report idle marking time below, but omit it from the
        // overall utilization here since it's "free".
-       markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime
+       markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load()
        markTermCpu := int64(work.stwprocs) * (work.tEnd - work.tMarkTerm)
        cycleCpu := sweepTermCpu + markCpu + markTermCpu
        work.totaltime += cycleCpu
@@ -1105,7 +1105,7 @@ func gcMarkTermination() {
                for i, ns := range []int64{
                        sweepTermCpu,
                        gcController.assistTime.Load(),
-                       gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime,
+                       gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load(),
                        gcController.idleMarkTime,
                        markTermCpu,
                } {
index d4991ad5def242142a7a077c8e853338c5801ae8..d687ffb65730768fa030625874bcb582b873abc9 100644 (file)
@@ -275,11 +275,11 @@ type gcControllerState struct {
        // phase.
        dedicatedMarkTime atomic.Int64
 
-       // fractionalMarkTime is the nanoseconds spent in the
-       // fractional mark worker during this cycle. This is updated
-       // atomically throughout the cycle and will be up-to-date if
-       // the fractional mark worker is not currently running.
-       fractionalMarkTime int64
+       // fractionalMarkTime is the nanoseconds spent in the fractional mark
+       // worker during this cycle. This is updated throughout the cycle and
+       // will be up-to-date if the fractional mark worker is not currently
+       // running.
+       fractionalMarkTime atomic.Int64
 
        // idleMarkTime is the nanoseconds spent in idle marking
        // during this cycle. This is updated atomically throughout
@@ -419,7 +419,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
        c.bgScanCredit.Store(0)
        c.assistTime.Store(0)
        c.dedicatedMarkTime.Store(0)
-       c.fractionalMarkTime = 0
+       c.fractionalMarkTime.Store(0)
        c.idleMarkTime = 0
        c.markStartTime = markStartTime
 
@@ -908,7 +908,7 @@ func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64
                c.dedicatedMarkTime.Add(duration)
                atomic.Xaddint64(&c.dedicatedMarkWorkersNeeded, 1)
        case gcMarkWorkerFractionalMode:
-               atomic.Xaddint64(&c.fractionalMarkTime, duration)
+               c.fractionalMarkTime.Add(duration)
        case gcMarkWorkerIdleMode:
                atomic.Xaddint64(&c.idleMarkTime, duration)
                c.removeIdleMarkWorker()