From 04d3d6bf48229942b7475e3964b3c097fe5a8c69 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 17 Aug 2022 17:43:56 +0700 Subject: [PATCH] runtime: convert profbuf.overflowTime to atomic type Updates #53821 Change-Id: I916549d831f84d4f1439433aea6a61ff5301d80c Reviewed-on: https://go-review.googlesource.com/c/go/+/423890 Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Run-TryBot: Cuong Manh Le Auto-Submit: Cuong Manh Le Reviewed-by: Michael Pratt --- src/runtime/profbuf.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/profbuf.go b/src/runtime/profbuf.go index 5e710812fb..5968c4ba77 100644 --- a/src/runtime/profbuf.go +++ b/src/runtime/profbuf.go @@ -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 } -- 2.48.1