aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-07-21 19:57:56 -0700
committerIan Lance Taylor <iant@golang.org>2021-07-22 21:53:16 +0000
commited8cbbc3ae96aef98d8f9e9e7003a99ed74992b5 (patch)
tree45f7d4b0d7ab98665d3d5caa64ee461433fbd904 /src/runtime
parentbc51e930274a5d5835ac8797978afc0864c9e30c (diff)
downloadgo-ed8cbbc3ae96aef98d8f9e9e7003a99ed74992b5.tar.gz
go-ed8cbbc3ae96aef98d8f9e9e7003a99ed74992b5.zip
[release-branch.go1.16] runtime: don't clear timerModifiedEarliest if adjustTimers is 0
This avoids a race when a new timerModifiedEarlier timer is created by a different goroutine. For #47329 Fixes #47332 Change-Id: I6f6c87b4a9b5491b201c725c10bc98e23e0ed9d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/336432 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> (cherry picked from commit 798ec73519a7226d6d436e42498a54aed23b8468) Reviewed-on: https://go-review.googlesource.com/c/go/+/336689
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime2.go2
-rw-r--r--src/runtime/time.go5
2 files changed, 1 insertions, 6 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 9a032d8658..dd375da193 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -653,7 +653,7 @@ type p struct {
// timerModifiedEarlier status. Because the timer may have been
// modified again, there need not be any timer with this value.
// This is updated using atomic functions.
- // This is 0 if the value is unknown.
+ // This is 0 if there are no timerModifiedEarlier timers.
timerModifiedEarliest uint64
// Per-P GC state
diff --git a/src/runtime/time.go b/src/runtime/time.go
index dee6a674e4..7b84d2af57 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -668,11 +668,6 @@ func adjusttimers(pp *p, now int64) {
if verifyTimers {
verifyTimerHeap(pp)
}
- // There are no timers to adjust, so it is safe to clear
- // timerModifiedEarliest. Do so in case it is stale.
- // Everything will work if we don't do this,
- // but clearing here may save future calls to adjusttimers.
- atomic.Store64(&pp.timerModifiedEarliest, 0)
return
}