Skip to content

Commit 89a6540

Browse files
committed
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 <[email protected]> Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Michael Pratt <[email protected]>
1 parent 9393b5b commit 89a6540

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/runtime/proc.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,9 +2606,10 @@ stop:
26062606
// safe-points. We don't need to snapshot the contents because
26072607
// everything up to cap(allp) is immutable.
26082608
allpSnapshot := allp
2609-
// Also snapshot idlepMask. Value changes are OK, but we can't allow
2609+
// Also snapshot masks. Value changes are OK, but we can't allow
26102610
// len to change out from under us.
26112611
idlepMaskSnapshot := idlepMask
2612+
timerpMaskSnapshot := timerpMask
26122613

26132614
// return P and block
26142615
lock(&sched.lock)
@@ -2670,10 +2671,12 @@ stop:
26702671
// transitioning from spinning to non-spinning. Note that we cannot use
26712672
// checkTimers here because it calls adjusttimers which may need to allocate
26722673
// memory, and that isn't allowed when we don't have an active P.
2673-
for _, _p_ := range allpSnapshot {
2674-
w := nobarrierWakeTime(_p_)
2675-
if w != 0 && (pollUntil == 0 || w < pollUntil) {
2676-
pollUntil = w
2674+
for id, _p_ := range allpSnapshot {
2675+
if timerpMaskSnapshot.read(uint32(id)) {
2676+
w := nobarrierWakeTime(_p_)
2677+
if w != 0 && (pollUntil == 0 || w < pollUntil) {
2678+
pollUntil = w
2679+
}
26772680
}
26782681
}
26792682
if pollUntil != 0 {

0 commit comments

Comments
 (0)