mirror of https://github.com/golang/go.git
runtime: make ncgocall a global counter
ncgocall was stored per M, runtime.NumCgoCall lost the counter when a M die. Fixes #46789
This commit is contained in:
parent
fb1d285d41
commit
cbc15fa870
|
|
@ -45,7 +45,7 @@ func NumCPU() int {
|
|||
|
||||
// NumCgoCall returns the number of cgo calls made by the current process.
|
||||
func NumCgoCall() int64 {
|
||||
var n = int64(ncgocall)
|
||||
var n = int64(atomic.Load64(&ncgocall))
|
||||
for mp := (*m)(atomic.Loadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink {
|
||||
n += int64(mp.ncgocall)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1507,7 +1507,6 @@ func mexit(osStack bool) {
|
|||
}
|
||||
throw("m not found in allm")
|
||||
found:
|
||||
ncgocall += m.ncgocall
|
||||
if !osStack {
|
||||
// Delay reaping m until it's done with the stack.
|
||||
//
|
||||
|
|
@ -1523,6 +1522,8 @@ found:
|
|||
}
|
||||
unlock(&sched.lock)
|
||||
|
||||
atomic.Xadd64(&ncgocall, int64(m.ncgocall))
|
||||
|
||||
// Release the P.
|
||||
handoffp(releasep())
|
||||
// After this point we must not have write barriers.
|
||||
|
|
|
|||
Loading…
Reference in New Issue