]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert profbuf.overflowTime to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 10:43:56 +0000 (17:43 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 18 Aug 2022 02:51:24 +0000 (02:51 +0000)
Updates #53821

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

index 5e710812fb4f7a516cd7a2f1fb750faa47b0ce29..5968c4ba7720dbba05cbdb937a94f1591d05f836 100644 (file)
@@ -88,7 +88,7 @@ type profBuf struct {
        // accessed atomically
        r, w         profAtomic
        overflow     atomic.Uint64
-       overflowTime uint64
+       overflowTime atomic.Uint64
        eof          uint32
 
        // immutable (excluding slice content)
@@ -158,7 +158,7 @@ func (b *profBuf) hasOverflow() bool {
 // When called by the reader, it is racing against incrementOverflow.
 func (b *profBuf) takeOverflow() (count uint32, time uint64) {
        overflow := b.overflow.Load()
-       time = atomic.Load64(&b.overflowTime)
+       time = b.overflowTime.Load()
        for {
                count = uint32(overflow)
                if count == 0 {
@@ -170,7 +170,7 @@ func (b *profBuf) takeOverflow() (count uint32, time uint64) {
                        break
                }
                overflow = b.overflow.Load()
-               time = atomic.Load64(&b.overflowTime)
+               time = b.overflowTime.Load()
        }
        return uint32(overflow), time
 }
@@ -185,7 +185,7 @@ func (b *profBuf) incrementOverflow(now int64) {
                // We need to set overflowTime if we're incrementing b.overflow from 0.
                if uint32(overflow) == 0 {
                        // Store overflowTime first so it's always available when overflow != 0.
-                       atomic.Store64(&b.overflowTime, uint64(now))
+                       b.overflowTime.Store(uint64(now))
                        b.overflow.Store((((overflow >> 32) + 1) << 32) + 1)
                        break
                }