]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert ticksType.val to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 19 Aug 2022 11:46:18 +0000 (18:46 +0700)
committerGopher Robot <gobot@golang.org>
Tue, 23 Aug 2022 20:00:03 +0000 (20:00 +0000)
Updates #53821

Change-Id: Ia0c58d7e7e11a1b52bbb7c19ebbb131e3eea5314
Reviewed-on: https://go-review.googlesource.com/c/go/+/424926
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/align_runtime_test.go
src/runtime/runtime.go

index 3a6a575481b243cd9a84dcf471b667614df9c83e..d78b0b2d39b26150f96658311a14ceb2ab786f20 100644 (file)
@@ -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),
 }
 
index e9fd56b46d24fe96073f20a40fe96d2f5fe22a7e..50f68a327caadcc78fbf5dc385dce9e5b46866c9 100644 (file)
@@ -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