mirror of
https://github.com/golang/go
synced 2024-11-23 05:30:07 -07:00
runtime: convert schedt.ngsys to atomic type
Note that this converts ngsys from uint32 to int32 to match the other (non-atomic) counters. For #53821. Change-Id: I3acbfbbd1dabc59b0ea5ddc86a97e0d0afa9f80c Reviewed-on: https://go-review.googlesource.com/c/go/+/419444 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
0fc774a68f
commit
449691b3ef
@ -1868,7 +1868,7 @@ func needm() {
|
|||||||
|
|
||||||
// mp.curg is now a real goroutine.
|
// mp.curg is now a real goroutine.
|
||||||
casgstatus(mp.curg, _Gdead, _Gsyscall)
|
casgstatus(mp.curg, _Gdead, _Gsyscall)
|
||||||
atomic.Xadd(&sched.ngsys, -1)
|
sched.ngsys.Add(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var earlycgocallback = []byte("fatal error: cgo callback before cgo call\n")
|
var earlycgocallback = []byte("fatal error: cgo callback before cgo call\n")
|
||||||
@ -1930,7 +1930,7 @@ func oneNewExtraM() {
|
|||||||
// counted by gcount. It would be more "proper" to increment
|
// counted by gcount. It would be more "proper" to increment
|
||||||
// sched.ngfree, but that requires locking. Incrementing ngsys
|
// sched.ngfree, but that requires locking. Incrementing ngsys
|
||||||
// has the same effect.
|
// has the same effect.
|
||||||
atomic.Xadd(&sched.ngsys, +1)
|
sched.ngsys.Add(1)
|
||||||
|
|
||||||
// Add m to the extra list.
|
// Add m to the extra list.
|
||||||
mnext := lockextra(true)
|
mnext := lockextra(true)
|
||||||
@ -1971,7 +1971,7 @@ func dropm() {
|
|||||||
// Return mp.curg to dead state.
|
// Return mp.curg to dead state.
|
||||||
casgstatus(mp.curg, _Gsyscall, _Gdead)
|
casgstatus(mp.curg, _Gsyscall, _Gdead)
|
||||||
mp.curg.preemptStop = false
|
mp.curg.preemptStop = false
|
||||||
atomic.Xadd(&sched.ngsys, +1)
|
sched.ngsys.Add(1)
|
||||||
|
|
||||||
// Block signals before unminit.
|
// Block signals before unminit.
|
||||||
// Unminit unregisters the signal handling stack (but needs g on some systems).
|
// Unminit unregisters the signal handling stack (but needs g on some systems).
|
||||||
@ -3474,7 +3474,7 @@ func goexit0(gp *g) {
|
|||||||
casgstatus(gp, _Grunning, _Gdead)
|
casgstatus(gp, _Grunning, _Gdead)
|
||||||
gcController.addScannableStack(pp, -int64(gp.stack.hi-gp.stack.lo))
|
gcController.addScannableStack(pp, -int64(gp.stack.hi-gp.stack.lo))
|
||||||
if isSystemGoroutine(gp, false) {
|
if isSystemGoroutine(gp, false) {
|
||||||
atomic.Xadd(&sched.ngsys, -1)
|
sched.ngsys.Add(-1)
|
||||||
}
|
}
|
||||||
gp.m = nil
|
gp.m = nil
|
||||||
locked := gp.lockedm != 0
|
locked := gp.lockedm != 0
|
||||||
@ -4141,7 +4141,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
|
|||||||
newg.ancestors = saveAncestors(callergp)
|
newg.ancestors = saveAncestors(callergp)
|
||||||
newg.startpc = fn.fn
|
newg.startpc = fn.fn
|
||||||
if isSystemGoroutine(newg, false) {
|
if isSystemGoroutine(newg, false) {
|
||||||
atomic.Xadd(&sched.ngsys, +1)
|
sched.ngsys.Add(1)
|
||||||
} else {
|
} else {
|
||||||
// Only user goroutines inherit pprof labels.
|
// Only user goroutines inherit pprof labels.
|
||||||
if mp.curg != nil {
|
if mp.curg != nil {
|
||||||
@ -4462,7 +4462,7 @@ func badunlockosthread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func gcount() int32 {
|
func gcount() int32 {
|
||||||
n := int32(atomic.Loaduintptr(&allglen)) - sched.gFree.n - int32(atomic.Load(&sched.ngsys))
|
n := int32(atomic.Loaduintptr(&allglen)) - sched.gFree.n - sched.ngsys.Load()
|
||||||
for _, pp := range allp {
|
for _, pp := range allp {
|
||||||
n -= pp.gFree.n
|
n -= pp.gFree.n
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ type schedt struct {
|
|||||||
nmsys int32 // number of system m's not counted for deadlock
|
nmsys int32 // number of system m's not counted for deadlock
|
||||||
nmfreed int64 // cumulative number of freed m's
|
nmfreed int64 // cumulative number of freed m's
|
||||||
|
|
||||||
ngsys uint32 // number of system goroutines; updated atomically
|
ngsys atomic.Int32 // number of system goroutines
|
||||||
|
|
||||||
pidle puintptr // idle p's
|
pidle puintptr // idle p's
|
||||||
npidle uint32
|
npidle uint32
|
||||||
|
Loading…
Reference in New Issue
Block a user