From: Michael Pratt Date: Thu, 1 Sep 2022 18:07:33 +0000 (+0000) Subject: Revert "runtime: convert ncgocall to atomic type" X-Git-Tag: go1.20rc1~1299 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ef8414101fba959c8df220ca0e544781029ce111;p=gostls13.git Revert "runtime: convert ncgocall to atomic type" This reverts CL 426075. Reason for revert: Import missing from cgocall.go. Change-Id: Iac17e914045b83da30484dbe2a624cde526fb175 Reviewed-on: https://go-review.googlesource.com/c/go/+/427614 Reviewed-by: Heschi Kreinick --- diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index 9d6568b292..0a25cb6562 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -111,7 +111,7 @@ func syscall_cgocaller(fn unsafe.Pointer, args ...uintptr) uintptr { return as.retval } -var ncgocall atomic.Uint64 // number of cgo calls in total for dead m +var ncgocall uint64 // number of cgo calls in total for dead m // Call from Go to C. // diff --git a/src/runtime/debug.go b/src/runtime/debug.go index 531c316b97..669c36f0d5 100644 --- a/src/runtime/debug.go +++ b/src/runtime/debug.go @@ -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.Load()) + var n = int64(atomic.Load64(&ncgocall)) for mp := (*m)(atomic.Loadp(unsafe.Pointer(&allm))); mp != nil; mp = mp.alllink { n += int64(mp.ncgocall) } diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 89cb5c70f0..6ecb786d1b 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -1530,7 +1530,7 @@ found: } unlock(&sched.lock) - ncgocall.Add(int64(mp.ncgocall)) + atomic.Xadd64(&ncgocall, int64(mp.ncgocall)) // Release the P. handoffp(releasep())