]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: handle timers on P's in procresize/(*pp).destroy
authorIan Lance Taylor <iant@golang.org>
Fri, 5 Apr 2019 23:53:13 +0000 (16:53 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 21 Oct 2019 23:18:36 +0000 (23:18 +0000)
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>
src/runtime/proc.go
src/runtime/time.go

index fd93a3db5fcc5a6876f41e63ba94a29289356f31..09ef784a0491fc1778083f37fc6b23c046d8a272 100644 (file)
@@ -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 {
index 1bbb5684cbc06681e858f82a6ef48e38a1dfc489..0148f47a9e5ccbcc4bcef4912f5c927b7c2d1b16 100644 (file)
@@ -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.