aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/time.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-10-29 16:23:27 -0700
committerIan Lance Taylor <iant@golang.org>2020-10-30 17:54:57 +0000
commite02ab89eb8994fa6f2dfa2924cdadb097633fcc1 (patch)
treeda5da8d8e31a01b1a6c9beae5ba8b99c98fa7456 /src/runtime/time.go
parenta313eec3869c609c0da2402a4cac2d32113d599c (diff)
downloadgo-e02ab89eb8994fa6f2dfa2924cdadb097633fcc1.tar.gz
go-e02ab89eb8994fa6f2dfa2924cdadb097633fcc1.zip
runtime: simplify nobarrierWakeTime
Also use the simplified nobarrierWakeTime in findrunnable, as it no longer needs the current time. Change-Id: I77b125d6a184dde0aeb517fc068164c274f0a046 Reviewed-on: https://go-review.googlesource.com/c/go/+/266304 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> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/time.go')
-rw-r--r--src/runtime/time.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/runtime/time.go b/src/runtime/time.go
index 99290f66d0..75b66f8492 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -742,16 +742,15 @@ func addAdjustedTimers(pp *p, moved []*timer) {
// nobarrierWakeTime looks at P's timers and returns the time when we
// should wake up the netpoller. It returns 0 if there are no timers.
// This function is invoked when dropping a P, and must run without
-// any write barriers. Therefore, if there are any timers that needs
-// to be moved earlier, it conservatively returns the current time.
-// The netpoller M will wake up and adjust timers before sleeping again.
+// any write barriers.
//go:nowritebarrierrec
func nobarrierWakeTime(pp *p) int64 {
- if atomic.Load(&pp.adjustTimers) > 0 {
- return nanotime()
- } else {
- return int64(atomic.Load64(&pp.timer0When))
+ next := int64(atomic.Load64(&pp.timer0When))
+ nextAdj := int64(atomic.Load64(&pp.timerModifiedEarliest))
+ if next == 0 || (nextAdj != 0 && nextAdj < next) {
+ next = nextAdj
}
+ return next
}
// runtimer examines the first timer in timers. If it is ready based on now,