]> Cypherpunks repositories - gostls13.git/commit
runtime: wake netpoller when dropping P, don't sleep too long in sysmon
authorIan Lance Taylor <iant@golang.org>
Fri, 1 Nov 2019 19:38:10 +0000 (12:38 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 4 Nov 2019 21:37:08 +0000 (21:37 +0000)
commitd80ab3e85a76581277f62761ae3c22817dab745d
tree3626681c30bfd668803b0fc2482235db831457e5
parent5a7c571ea19a0d859222d6c92d108fdc68da9f13
runtime: wake netpoller when dropping P, don't sleep too long in sysmon

When dropping a P, if it has any timers, and if some thread is
sleeping in the netpoller, wake the netpoller to run the P's timers.
This mitigates races between the netpoller deciding how long to sleep
and a new timer being added.

In sysmon, if all P's are idle, check the timers to decide how long to sleep.
This avoids oversleeping if no thread is using the netpoller.
This can happen in particular if some threads use runtime.LockOSThread,
as those threads do not block in the netpoller.

Also, print the number of timers per P for GODEBUG=scheddetail=1.

Before this CL, TestLockedDeadlock2 would fail about 1% of the time.
With this CL, I ran it 150,000 times with no failures.

Updates #6239
Updates #27707
Fixes #35274
Fixes #35288

Change-Id: I7e5193e6c885e567f0b1ee023664aa3e2902fcd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/204800
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