mirror of
https://github.com/golang/go
synced 2024-09-30 02:24:43 -06:00
runtime: convert m.signalPending to atomic type
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>
This commit is contained in:
parent
014f0e8205
commit
b11b4b4de3
@ -1547,7 +1547,7 @@ found:
|
|||||||
if GOOS == "darwin" || GOOS == "ios" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
// Make sure pendingPreemptSignals is correct when an M exits.
|
// Make sure pendingPreemptSignals is correct when an M exits.
|
||||||
// For #41702.
|
// For #41702.
|
||||||
if atomic.Load(&mp.signalPending) != 0 {
|
if mp.signalPending.Load() != 0 {
|
||||||
pendingPreemptSignals.Add(-1)
|
pendingPreemptSignals.Add(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,8 +587,7 @@ type m struct {
|
|||||||
preemptGen uint32
|
preemptGen uint32
|
||||||
|
|
||||||
// Whether this is a pending preemption signal on this M.
|
// Whether this is a pending preemption signal on this M.
|
||||||
// Accessed atomically.
|
signalPending atomic.Uint32
|
||||||
signalPending uint32
|
|
||||||
|
|
||||||
dlogPerM
|
dlogPerM
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ func doSigPreempt(gp *g, ctxt *sigctxt) {
|
|||||||
|
|
||||||
// Acknowledge the preemption.
|
// Acknowledge the preemption.
|
||||||
atomic.Xadd(&gp.m.preemptGen, 1)
|
atomic.Xadd(&gp.m.preemptGen, 1)
|
||||||
atomic.Store(&gp.m.signalPending, 0)
|
gp.m.signalPending.Store(0)
|
||||||
|
|
||||||
if GOOS == "darwin" || GOOS == "ios" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
pendingPreemptSignals.Add(-1)
|
pendingPreemptSignals.Add(-1)
|
||||||
@ -372,7 +372,7 @@ func preemptM(mp *m) {
|
|||||||
execLock.rlock()
|
execLock.rlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if atomic.Cas(&mp.signalPending, 0, 1) {
|
if mp.signalPending.CompareAndSwap(0, 1) {
|
||||||
if GOOS == "darwin" || GOOS == "ios" {
|
if GOOS == "darwin" || GOOS == "ios" {
|
||||||
pendingPreemptSignals.Add(1)
|
pendingPreemptSignals.Add(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user