]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert m.cgoCallersUse to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 10:39:01 +0000 (17:39 +0700)
committerGopher Robot <gobot@golang.org>
Thu, 18 Aug 2022 02:34:04 +0000 (02:34 +0000)
Updates #53821

Change-Id: I99b01f8e91b798e73275635c8a63fcdc4a8df9f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/423888
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/traceback.go

index 01f9ed5f5791937c5df9bebc07c25cc653e83fcd..1b33d59736f28eeb71845cd52b4f0a734a361539 100644 (file)
@@ -4609,7 +4609,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
                // cgoCallers.  We are running in a signal handler
                // with all signals blocked, so we don't have to worry
                // about any other code interrupting us.
-               if atomic.Load(&mp.cgoCallersUse) == 0 && mp.cgoCallers != nil && mp.cgoCallers[0] != 0 {
+               if mp.cgoCallersUse.Load() == 0 && mp.cgoCallers != nil && mp.cgoCallers[0] != 0 {
                        for cgoOff < len(mp.cgoCallers) && mp.cgoCallers[cgoOff] != 0 {
                                cgoOff++
                        }
index 79c8ccb6ec5971fa21acfb950afe0d7957dd4ec0..21dba96a59857596830d5c595ea0a96a485916e7 100644 (file)
@@ -550,10 +550,10 @@ type m struct {
        fastrand      uint64
        needextram    bool
        traceback     uint8
-       ncgocall      uint64      // number of cgo calls in total
-       ncgo          int32       // number of cgo calls currently in progress
-       cgoCallersUse uint32      // if non-zero, cgoCallers in use temporarily
-       cgoCallers    *cgoCallers // cgo traceback if crashing in cgo call
+       ncgocall      uint64        // number of cgo calls in total
+       ncgo          int32         // number of cgo calls currently in progress
+       cgoCallersUse atomic.Uint32 // if non-zero, cgoCallers in use temporarily
+       cgoCallers    *cgoCallers   // cgo traceback if crashing in cgo call
        park          note
        alllink       *m // on allm
        schedlink     muintptr
index 96cf82c23e26d402c0abc925cf46d0935890e50c..599141af94c0e5106312aac4439cb2ff8a7f97b8 100644 (file)
@@ -7,7 +7,6 @@ package runtime
 import (
        "internal/bytealg"
        "internal/goarch"
-       "runtime/internal/atomic"
        "runtime/internal/sys"
        "unsafe"
 )
@@ -819,10 +818,10 @@ func traceback1(pc, sp, lr uintptr, gp *g, flags uint) {
                // concurrently with a signal handler.
                // We just have to stop a signal handler from interrupting
                // in the middle of our copy.
-               atomic.Store(&gp.m.cgoCallersUse, 1)
+               gp.m.cgoCallersUse.Store(1)
                cgoCallers := *gp.m.cgoCallers
                gp.m.cgoCallers[0] = 0
-               atomic.Store(&gp.m.cgoCallersUse, 0)
+               gp.m.cgoCallersUse.Store(0)
 
                printCgoTraceback(&cgoCallers)
        }