Skip to content

Commit 6b3bb4b

Browse files
runtime: handle timers on P's in procresize/(*pp).destroy
Updates #6239 Updates #27707 Change-Id: I52cab8bf3dc8c552463725fc1d9e4e6b12230b03 Reviewed-on: https://go-review.googlesource.com/c/go/+/171828 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 9989221 commit 6b3bb4b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/runtime/proc.go

+6
Original file line numberDiff line numberDiff line change
@@ -4117,6 +4117,12 @@ func (pp *p) destroy() {
41174117
globrunqputhead(pp.runnext.ptr())
41184118
pp.runnext = 0
41194119
}
4120+
if len(pp.timers) > 0 {
4121+
plocal := getg().m.p.ptr()
4122+
// The world is stopped so we don't need to hold timersLock.
4123+
moveTimers(plocal, pp.timers)
4124+
pp.timers = nil
4125+
}
41204126
// If there's a background worker, make it runnable and put
41214127
// it on the global queue so it can clean itself up.
41224128
if gp := pp.gcBgMarkWorker.ptr(); gp != nil {

src/runtime/time.go

+8
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,14 @@ func timerproc(tb *timersBucket) {
325325
}
326326
}
327327

328+
// moveTimers moves a slice of timers to pp. The slice has been taken
329+
// from a different P.
330+
// This is currently called when the world is stopped, but it could
331+
// work as long as the timers for pp are locked.
332+
func moveTimers(pp *p, timers []*timer) {
333+
throw("movetimers: not yet implemented")
334+
}
335+
328336
// adjusttimers looks through the timers in the current P's heap for
329337
// any timers that have been modified to run earlier, and puts them in
330338
// the correct place in the heap.

0 commit comments

Comments
 (0)