Skip to content

Commit

Permalink
runtime: handle timers on P's in procresize/(*pp).destroy
Browse files Browse the repository at this point in the history
Updates #6239
Updates #27707

Change-Id: I52cab8bf3dc8c552463725fc1d9e4e6b12230b03
Reviewed-on: https://go-review.googlesource.com/c/go/+/171828
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
  • Loading branch information
ianlancetaylor committed Oct 21, 2019
1 parent 9989221 commit 6b3bb4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/runtime/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,12 @@ func (pp *p) destroy() {
globrunqputhead(pp.runnext.ptr())
pp.runnext = 0
}
if len(pp.timers) > 0 {
plocal := getg().m.p.ptr()
// The world is stopped so we don't need to hold timersLock.
moveTimers(plocal, pp.timers)
pp.timers = nil
}
// If there's a background worker, make it runnable and put
// it on the global queue so it can clean itself up.
if gp := pp.gcBgMarkWorker.ptr(); gp != nil {
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ func timerproc(tb *timersBucket) {
}
}

// moveTimers moves a slice of timers to pp. The slice has been taken
// from a different P.
// This is currently called when the world is stopped, but it could
// work as long as the timers for pp are locked.
func moveTimers(pp *p, timers []*timer) {
throw("movetimers: not yet implemented")
}

// adjusttimers looks through the timers in the current P's heap for
// any timers that have been modified to run earlier, and puts them in
// the correct place in the heap.
Expand Down

0 comments on commit 6b3bb4b

Please sign in to comment.