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>
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.
//
// 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)
}
}
unlock(&sched.lock)
- atomic.Xadd64(&ncgocall, int64(mp.ncgocall))
+ ncgocall.Add(int64(mp.ncgocall))
// Release the P.
handoffp(releasep())