aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2023-05-18 15:51:57 +0000
committerMichael Knyszek <mknyszek@google.com>2023-05-23 19:24:33 +0000
commit6f13d0bfe42115d1d5452bee0bb7648d968beeb4 (patch)
treedd50d8bea8397895dddbb29614a62b907773afe4 /src/runtime/proc.go
parent5124371c1c7d6e2f5c8ebf821fdd07ea71d564c7 (diff)
downloadgo-6f13d0bfe42115d1d5452bee0bb7648d968beeb4.tar.xz
runtime: fix usage of stale "now" value for netpolling Ms
Currently pidleget gets passed "now" from before the M goes into netpoll, resulting in incorrect accounting of idle CPU time. lastpoll is also stored with a stale "now": the mistake was added in the same CL it was added for pidleget. Recompute "now" after returning from netpoll. Also, start tracking idle time on js/wasm at all. Credit to Rhys Hiltner for the test case. Fixes #60276. Change-Id: I5dd677471f74c915dfcf3d01621430876c3ff307 Reviewed-on: https://go-review.googlesource.com/c/go/+/496183 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 276d7355e9..56518fd3af 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -3145,10 +3145,11 @@ top:
if mp.spinning {
throw("findrunnable: netpoll with spinning")
}
- // Refresh now.
- now = nanotime()
delay := int64(-1)
if pollUntil != 0 {
+ if now == 0 {
+ now = nanotime()
+ }
delay = pollUntil - now
if delay < 0 {
delay = 0
@@ -3159,6 +3160,8 @@ top:
delay = 0
}
list := netpoll(delay) // block until new work is available
+ // Refresh now again, after potentially blocking.
+ now = nanotime()
sched.pollUntil.Store(0)
sched.lastpoll.Store(now)
if faketime != 0 && list.empty() {