aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2022-07-15 16:47:03 -0400
committerMichael Pratt <mpratt@google.com>2022-08-08 14:12:03 +0000
commitfe406c8b11aa6e94c91f2d1fe05c170e3af2dc1e (patch)
tree2157d0901bcdb669318b315a14fcb40845cfbeef /src/runtime
parent3ea3d0e8a7f4e2bfa96535aafb6bd802d2907808 (diff)
downloadgo-fe406c8b11aa6e94c91f2d1fe05c170e3af2dc1e.tar.xz
runtime: convert gcController.fractionalMarkTime to atomic type
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>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/align_runtime_test.go1
-rw-r--r--src/runtime/mgc.go4
-rw-r--r--src/runtime/mgcpacer.go14
3 files changed, 9 insertions, 10 deletions
diff --git a/src/runtime/align_runtime_test.go b/src/runtime/align_runtime_test.go
index bca01e23e2..98e1622e7a 100644
--- a/src/runtime/align_runtime_test.go
+++ b/src/runtime/align_runtime_test.go
@@ -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),
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 06ea86929a..01eee16a4d 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -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,
} {
diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go
index d4991ad5de..d687ffb657 100644
--- a/src/runtime/mgcpacer.go
+++ b/src/runtime/mgcpacer.go
@@ -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()