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

Change-Id: I772b58b21392855af95ee5b932cdd7a0b507e4e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/417781
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>

src/runtime/align_runtime_test.go
src/runtime/mgc.go
src/runtime/mgcpacer.go

index 252f59f158ffe04e584c06b3328b956803f484b5..bca01e23e216dfef95f301fceabd4a22417e977b 100644 (file)
@@ -21,7 +21,6 @@ var AtomicFields = []uintptr{
        unsafe.Offsetof(schedt{}.lastpoll),
        unsafe.Offsetof(schedt{}.pollUntil),
        unsafe.Offsetof(schedt{}.timeToRun),
-       unsafe.Offsetof(gcControllerState{}.dedicatedMarkTime),
        unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
        unsafe.Offsetof(gcControllerState{}.fractionalMarkTime),
        unsafe.Offsetof(gcControllerState{}.idleMarkTime),
index 0a0de568e3e499cc1a928d759b1093f780f4a801..06ea86929a14fd69ededf392c9afd1f014a1bb3b 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 + gcController.fractionalMarkTime
+       markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime
        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 + gcController.fractionalMarkTime,
+                       gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime,
                        gcController.idleMarkTime,
                        markTermCpu,
                } {
index b8483cc12b563f110580b3f036b19f23d45d4476..d4991ad5def242142a7a077c8e853338c5801ae8 100644 (file)
@@ -270,10 +270,10 @@ type gcControllerState struct {
        // written and read throughout the cycle.
        assistTime atomic.Int64
 
-       // dedicatedMarkTime is the nanoseconds spent in dedicated
-       // mark workers during this cycle. This is updated atomically
-       // at the end of the concurrent mark phase.
-       dedicatedMarkTime int64
+       // dedicatedMarkTime is the nanoseconds spent in dedicated mark workers
+       // during this cycle. This is updated at the end of the concurrent mark
+       // phase.
+       dedicatedMarkTime atomic.Int64
 
        // fractionalMarkTime is the nanoseconds spent in the
        // fractional mark worker during this cycle. This is updated
@@ -418,7 +418,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
        c.globalsScanWork.Store(0)
        c.bgScanCredit.Store(0)
        c.assistTime.Store(0)
-       c.dedicatedMarkTime = 0
+       c.dedicatedMarkTime.Store(0)
        c.fractionalMarkTime = 0
        c.idleMarkTime = 0
        c.markStartTime = markStartTime
@@ -905,7 +905,7 @@ func (c *gcControllerState) resetLive(bytesMarked uint64) {
 func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64) {
        switch mode {
        case gcMarkWorkerDedicatedMode:
-               atomic.Xaddint64(&c.dedicatedMarkTime, duration)
+               c.dedicatedMarkTime.Add(duration)
                atomic.Xaddint64(&c.dedicatedMarkWorkersNeeded, 1)
        case gcMarkWorkerFractionalMode:
                atomic.Xaddint64(&c.fractionalMarkTime, duration)