mirror of https://github.com/golang/go.git
runtime: convert netpollWaiters to internal atomic type
Updates #53821 Change-Id: I8776382b3eb0b7752cfc0d9287b707039d3f05c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/425358 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: hopehook <hopehook@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
73a55c1704
commit
aab8d2b448
|
|
@ -181,7 +181,7 @@ var (
|
|||
netpollInited atomic.Uint32
|
||||
|
||||
pollcache pollCache
|
||||
netpollWaiters uint32
|
||||
netpollWaiters atomic.Uint32
|
||||
)
|
||||
|
||||
//go:linkname poll_runtime_pollServerInit internal/poll.runtime_pollServerInit
|
||||
|
|
@ -483,13 +483,13 @@ func netpollblockcommit(gp *g, gpp unsafe.Pointer) bool {
|
|||
// Bump the count of goroutines waiting for the poller.
|
||||
// The scheduler uses this to decide whether to block
|
||||
// waiting for the poller if there is nothing else to do.
|
||||
atomic.Xadd(&netpollWaiters, 1)
|
||||
netpollWaiters.Add(1)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func netpollgoready(gp *g, traceskip int) {
|
||||
atomic.Xadd(&netpollWaiters, -1)
|
||||
netpollWaiters.Add(-1)
|
||||
goready(gp, traceskip+1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ package runtime
|
|||
import "runtime/internal/atomic"
|
||||
|
||||
var netpollInited atomic.Uint32
|
||||
var netpollWaiters uint32
|
||||
var netpollWaiters atomic.Uint32
|
||||
|
||||
var netpollStubLock mutex
|
||||
var netpollNote note
|
||||
|
|
|
|||
|
|
@ -2659,7 +2659,7 @@ top:
|
|||
// blocked thread (e.g. it has already returned from netpoll, but does
|
||||
// not set lastpoll yet), this thread will do blocking netpoll below
|
||||
// anyway.
|
||||
if netpollinited() && atomic.Load(&netpollWaiters) > 0 && sched.lastpoll.Load() != 0 {
|
||||
if netpollinited() && netpollWaiters.Load() > 0 && sched.lastpoll.Load() != 0 {
|
||||
if list := netpoll(0); !list.empty() { // non-blocking
|
||||
gp := list.pop()
|
||||
injectglist(&list)
|
||||
|
|
@ -2851,7 +2851,7 @@ top:
|
|||
}
|
||||
|
||||
// Poll network until next timer.
|
||||
if netpollinited() && (atomic.Load(&netpollWaiters) > 0 || pollUntil != 0) && sched.lastpoll.Swap(0) != 0 {
|
||||
if netpollinited() && (netpollWaiters.Load() > 0 || pollUntil != 0) && sched.lastpoll.Swap(0) != 0 {
|
||||
sched.pollUntil.Store(pollUntil)
|
||||
if mp.p != 0 {
|
||||
throw("findrunnable: netpoll with p")
|
||||
|
|
@ -2924,7 +2924,7 @@ func pollWork() bool {
|
|||
if !runqempty(p) {
|
||||
return true
|
||||
}
|
||||
if netpollinited() && atomic.Load(&netpollWaiters) > 0 && sched.lastpoll.Load() != 0 {
|
||||
if netpollinited() && netpollWaiters.Load() > 0 && sched.lastpoll.Load() != 0 {
|
||||
if list := netpoll(0); !list.empty() {
|
||||
injectglist(&list)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in New Issue