]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert m.signalPending to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 10:33:39 +0000 (17:33 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 16:48:18 +0000 (16:48 +0000)
Updates #53821

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

src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/signal_unix.go

index 1de1ed781f2b5aaa9ee9b173d620f3d7134b15b8..0e74eb1075dfa119474ecfa8adc8a600a13d33da 100644 (file)
@@ -1547,7 +1547,7 @@ found:
        if GOOS == "darwin" || GOOS == "ios" {
                // Make sure pendingPreemptSignals is correct when an M exits.
                // For #41702.
-               if atomic.Load(&mp.signalPending) != 0 {
+               if mp.signalPending.Load() != 0 {
                        pendingPreemptSignals.Add(-1)
                }
        }
index 2fbb1d1744d0d99c85c72e7157c667ded68ab68d..3cf0e8e98b57c28961feebde668dff82c499666c 100644 (file)
@@ -587,8 +587,7 @@ type m struct {
        preemptGen uint32
 
        // Whether this is a pending preemption signal on this M.
-       // Accessed atomically.
-       signalPending uint32
+       signalPending atomic.Uint32
 
        dlogPerM
 
index 66a4650b5819449370debeaac20bd541da746114..4c3f43a819acab25a1193d95e3b76f631d0f8057 100644 (file)
@@ -350,7 +350,7 @@ func doSigPreempt(gp *g, ctxt *sigctxt) {
 
        // Acknowledge the preemption.
        atomic.Xadd(&gp.m.preemptGen, 1)
-       atomic.Store(&gp.m.signalPending, 0)
+       gp.m.signalPending.Store(0)
 
        if GOOS == "darwin" || GOOS == "ios" {
                pendingPreemptSignals.Add(-1)
@@ -372,7 +372,7 @@ func preemptM(mp *m) {
                execLock.rlock()
        }
 
-       if atomic.Cas(&mp.signalPending, 0, 1) {
+       if mp.signalPending.CompareAndSwap(0, 1) {
                if GOOS == "darwin" || GOOS == "ios" {
                        pendingPreemptSignals.Add(1)
                }