mirror of
https://github.com/golang/go
synced 2024-11-17 01:04:50 -07:00
runtime: convert mOS.profileTimerValid to internal atomic type
For #53821 Change-Id: I6ef90867e918d4907baa83c5a811f1f93e8c09a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/426196 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
28e388589b
commit
d3b35a4242
@ -21,12 +21,12 @@ type mOS struct {
|
||||
// profileTimer holds the ID of the POSIX interval timer for profiling CPU
|
||||
// usage on this thread.
|
||||
//
|
||||
// It is valid when the profileTimerValid field is non-zero. A thread
|
||||
// It is valid when the profileTimerValid field is true. A thread
|
||||
// creates and manages its own timer, and these fields are read and written
|
||||
// only by this thread. But because some of the reads on profileTimerValid
|
||||
// are in signal handling code, access to that field uses atomic operations.
|
||||
// are in signal handling code, this field should be atomic type.
|
||||
profileTimer int32
|
||||
profileTimerValid uint32
|
||||
profileTimerValid atomic.Bool
|
||||
|
||||
// needPerThreadSyscall indicates that a per-thread syscall is required
|
||||
// for doAllThreadsSyscall.
|
||||
@ -593,7 +593,7 @@ func validSIGPROF(mp *m, c *sigctxt) bool {
|
||||
|
||||
// Having an M means the thread interacts with the Go scheduler, and we can
|
||||
// check whether there's an active per-thread timer for this thread.
|
||||
if atomic.Load(&mp.profileTimerValid) != 0 {
|
||||
if mp.profileTimerValid.Load() {
|
||||
// If this M has its own per-thread CPU profiling interval timer, we
|
||||
// should track the SIGPROF signals that come from that timer (for
|
||||
// accurate reporting of its CPU usage; see issue 35057) and ignore any
|
||||
@ -619,9 +619,9 @@ func setThreadCPUProfiler(hz int32) {
|
||||
}
|
||||
|
||||
// destroy any active timer
|
||||
if atomic.Load(&mp.profileTimerValid) != 0 {
|
||||
if mp.profileTimerValid.Load() {
|
||||
timerid := mp.profileTimer
|
||||
atomic.Store(&mp.profileTimerValid, 0)
|
||||
mp.profileTimerValid.Store(false)
|
||||
mp.profileTimer = 0
|
||||
|
||||
ret := timer_delete(timerid)
|
||||
@ -681,7 +681,7 @@ func setThreadCPUProfiler(hz int32) {
|
||||
}
|
||||
|
||||
mp.profileTimer = timerid
|
||||
atomic.Store(&mp.profileTimerValid, 1)
|
||||
mp.profileTimerValid.Store(true)
|
||||
}
|
||||
|
||||
// perThreadSyscallArgs contains the system call number, arguments, and
|
||||
|
Loading…
Reference in New Issue
Block a user