From: Cuong Manh Le Date: Fri, 19 Aug 2022 11:46:18 +0000 (+0700) Subject: runtime: convert ticksType.val to atomic type X-Git-Tag: go1.20rc1~1454 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e1114fdf883de7484c49343d966fd9759ce48c40;p=gostls13.git runtime: convert ticksType.val to atomic type Updates #53821 Change-Id: Ia0c58d7e7e11a1b52bbb7c19ebbb131e3eea5314 Reviewed-on: https://go-review.googlesource.com/c/go/+/424926 Reviewed-by: Michael Knyszek Run-TryBot: Cuong Manh Le Auto-Submit: Cuong Manh Le TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt --- diff --git a/src/runtime/align_runtime_test.go b/src/runtime/align_runtime_test.go index 3a6a575481..d78b0b2d39 100644 --- a/src/runtime/align_runtime_test.go +++ b/src/runtime/align_runtime_test.go @@ -33,7 +33,6 @@ var AtomicFields = []uintptr{ unsafe.Offsetof(lfnode{}.next), unsafe.Offsetof(mstats{}.last_gc_nanotime), unsafe.Offsetof(mstats{}.last_gc_unix), - unsafe.Offsetof(ticksType{}.val), unsafe.Offsetof(workType{}.bytesMarked), } diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index e9fd56b46d..50f68a327c 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -18,18 +18,17 @@ var ticks ticksType type ticksType struct { lock mutex - pad uint32 // ensure 8-byte alignment of val on 386 - val uint64 + val atomic.Int64 } // Note: Called by runtime/pprof in addition to runtime code. func tickspersecond() int64 { - r := int64(atomic.Load64(&ticks.val)) + r := ticks.val.Load() if r != 0 { return r } lock(&ticks.lock) - r = int64(ticks.val) + r = ticks.val.Load() if r == 0 { t0 := nanotime() c0 := cputicks() @@ -43,7 +42,7 @@ func tickspersecond() int64 { if r == 0 { r++ } - atomic.Store64(&ticks.val, uint64(r)) + ticks.val.Store(r) } unlock(&ticks.lock) return r