From: Michael Pratt Date: Thu, 29 Oct 2020 20:03:57 +0000 (-0400) Subject: runtime: elide timer re-check if P has no timers X-Git-Tag: go1.16beta1~381 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=89a6540d8a93b95620080a8145c9882b063e3e46;p=gostls13.git runtime: elide timer re-check if P has no timers In golang.org/cl/264477, I missed this new block after rebasing past golang.org/cl/232298. These fields must be zero if there are no timers. Updates #28808 Updates #18237 Change-Id: I2d9e1cbf326497c833daa26b11aed9a1e12c2270 Reviewed-on: https://go-review.googlesource.com/c/go/+/266367 Run-TryBot: Michael Pratt Reviewed-by: Austin Clements Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Knyszek TryBot-Result: Go Bot Trust: Michael Pratt --- diff --git a/src/runtime/proc.go b/src/runtime/proc.go index ced27ceb3a..071257b5a5 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -2606,9 +2606,10 @@ stop: // safe-points. We don't need to snapshot the contents because // everything up to cap(allp) is immutable. allpSnapshot := allp - // Also snapshot idlepMask. Value changes are OK, but we can't allow + // Also snapshot masks. Value changes are OK, but we can't allow // len to change out from under us. idlepMaskSnapshot := idlepMask + timerpMaskSnapshot := timerpMask // return P and block lock(&sched.lock) @@ -2670,10 +2671,12 @@ stop: // transitioning from spinning to non-spinning. Note that we cannot use // checkTimers here because it calls adjusttimers which may need to allocate // memory, and that isn't allowed when we don't have an active P. - for _, _p_ := range allpSnapshot { - w := nobarrierWakeTime(_p_) - if w != 0 && (pollUntil == 0 || w < pollUntil) { - pollUntil = w + for id, _p_ := range allpSnapshot { + if timerpMaskSnapshot.read(uint32(id)) { + w := nobarrierWakeTime(_p_) + if w != 0 && (pollUntil == 0 || w < pollUntil) { + pollUntil = w + } } } if pollUntil != 0 {