mirror of
https://github.com/golang/go
synced 2024-11-16 20:04:52 -07:00
runtime: convert ncgocall to atomic type
For #53821 Change-Id: Ib0d62ee36487b3ed68e063976968f3cac6499e4b Reviewed-on: https://go-review.googlesource.com/c/go/+/426075 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
af991a6d28
commit
5a6db7c48f
@ -111,7 +111,7 @@ func syscall_cgocaller(fn unsafe.Pointer, args ...uintptr) uintptr {
|
||||
return as.retval
|
||||
}
|
||||
|
||||
var ncgocall uint64 // number of cgo calls in total for dead m
|
||||
var ncgocall atomic.Uint64 // number of cgo calls in total for dead m
|
||||
|
||||
// Call from Go to C.
|
||||
//
|
||||
|
@ -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(atomic.Load64(&ncgocall))
|
||||
var n = int64(ncgocall.Load())
|
||||
for mp := (*m)(atomic.Loadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink {
|
||||
n += int64(mp.ncgocall)
|
||||
}
|
||||
|
@ -1530,7 +1530,7 @@ found:
|
||||
}
|
||||
unlock(&sched.lock)
|
||||
|
||||
atomic.Xadd64(&ncgocall, int64(mp.ncgocall))
|
||||
ncgocall.Add(int64(mp.ncgocall))
|
||||
|
||||
// Release the P.
|
||||
handoffp(releasep())
|
||||
|
Loading…
Reference in New Issue
Block a user