]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert p.timer0When to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 07:56:18 +0000 (14:56 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 17 Aug 2022 18:01:43 +0000 (18:01 +0000)
Updates #53821

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

src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/time.go

index b57644cc21de547884121f018f1f3bcbf858214f..f100e321d44a741a729ee5966d5d9ef1ff645e50 100644 (file)
@@ -3329,7 +3329,7 @@ func dropg() {
 func checkTimers(pp *p, now int64) (rnow, pollUntil int64, ran bool) {
        // If it's not yet time for the first timer, or the first adjusted
        // timer, then there is nothing to do.
-       next := int64(atomic.Load64(&pp.timer0When))
+       next := int64(pp.timer0When.Load())
        nextAdj := int64(atomic.Load64(&pp.timerModifiedEarliest))
        if next == 0 || (nextAdj != 0 && nextAdj < next) {
                next = nextAdj
@@ -4787,7 +4787,7 @@ func (pp *p) destroy() {
                pp.timers = nil
                pp.numTimers = 0
                pp.deletedTimers = 0
-               atomic.Store64(&pp.timer0When, 0)
+               pp.timer0When.Store(0)
                unlock(&pp.timersLock)
                unlock(&plocal.timersLock)
        }
index 63ba5348158ea70cea137bc985be910cb4864e63..34638d9fb3c1a65c70aa79d306fa1f80e44a2cad 100644 (file)
@@ -670,9 +670,8 @@ type p struct {
        _ uint32 // Alignment for atomic fields below
 
        // The when field of the first entry on the timer heap.
-       // This is updated using atomic functions.
        // This is 0 if the timer heap is empty.
-       timer0When uint64
+       timer0When atomic.Uint64
 
        // The earliest known nextwhen field of a timer with
        // timerModifiedEarlier status. Because the timer may have been
index a4bbc53cfa4748ef9b8e39ce733fac91b675d19b..0ab2c9c21d2cd269e4f8186bc6c3591e8f39592c 100644 (file)
@@ -301,7 +301,7 @@ func doaddtimer(pp *p, t *timer) {
        pp.timers = append(pp.timers, t)
        siftupTimer(pp.timers, i)
        if t == pp.timers[0] {
-               atomic.Store64(&pp.timer0When, uint64(t.when))
+               pp.timer0When.Store(uint64(t.when))
        }
        atomic.Xadd(&pp.numTimers, 1)
 }
@@ -754,7 +754,7 @@ func addAdjustedTimers(pp *p, moved []*timer) {
 //
 //go:nowritebarrierrec
 func nobarrierWakeTime(pp *p) int64 {
-       next := int64(atomic.Load64(&pp.timer0When))
+       next := int64(pp.timer0When.Load())
        nextAdj := int64(atomic.Load64(&pp.timerModifiedEarliest))
        if next == 0 || (nextAdj != 0 && nextAdj < next) {
                next = nextAdj
@@ -1003,9 +1003,9 @@ func verifyTimerHeap(pp *p) {
 // The caller must have locked the timers for pp.
 func updateTimer0When(pp *p) {
        if len(pp.timers) == 0 {
-               atomic.Store64(&pp.timer0When, 0)
+               pp.timer0When.Store(0)
        } else {
-               atomic.Store64(&pp.timer0When, uint64(pp.timers[0].when))
+               pp.timer0When.Store(uint64(pp.timers[0].when))
        }
 }
 
@@ -1039,7 +1039,7 @@ func timeSleepUntil() int64 {
                        continue
                }
 
-               w := int64(atomic.Load64(&pp.timer0When))
+               w := int64(pp.timer0When.Load())
                if w != 0 && w < next {
                        next = w
                }