]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert schedt.goidgen to atomic type
authorMichael Pratt <mpratt@google.com>
Tue, 19 Jul 2022 17:34:29 +0000 (13:34 -0400)
committerMichael Pratt <mpratt@google.com>
Fri, 12 Aug 2022 01:39:14 +0000 (01:39 +0000)
For #53821.

Change-Id: I84c96ade5982b8e68d1d1787bf1bfa16a17a4fb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/419439
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/align_runtime_test.go
src/runtime/proc.go
src/runtime/runtime2.go

index de5a5c639c6c0c95d3eb2c445eaa7050ebfe65c6..18a3908fda14e08c1f28990f468319f35eac0dee 100644 (file)
@@ -17,7 +17,6 @@ var AtomicFields = []uintptr{
        unsafe.Offsetof(p{}.timer0When),
        unsafe.Offsetof(p{}.timerModifiedEarliest),
        unsafe.Offsetof(p{}.gcFractionalMarkTime),
-       unsafe.Offsetof(schedt{}.goidgen),
        unsafe.Offsetof(schedt{}.lastpoll),
        unsafe.Offsetof(schedt{}.pollUntil),
        unsafe.Offsetof(schedt{}.timeToRun),
index 33d7d6f552fd7d2957ce388150df16deed98d564..d9df526f7ef4fec6fd1922b62b8c7c20ac3ad2f2 100644 (file)
@@ -1919,7 +1919,7 @@ func oneNewExtraM() {
        mp.lockedInt++
        mp.lockedg.set(gp)
        gp.lockedm.set(mp)
-       gp.goid = int64(atomic.Xadd64(&sched.goidgen, 1))
+       gp.goid = int64(sched.goidgen.Add(1))
        if raceenabled {
                gp.racectx = racegostart(abi.FuncPCABIInternal(newextram) + sys.PCQuantum)
        }
@@ -4168,7 +4168,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
                // Sched.goidgen is the last allocated id,
                // this batch must be [sched.goidgen+1, sched.goidgen+GoidCacheBatch].
                // At startup sched.goidgen=0, so main goroutine receives goid=1.
-               pp.goidcache = atomic.Xadd64(&sched.goidgen, _GoidCacheBatch)
+               pp.goidcache = sched.goidgen.Add(_GoidCacheBatch)
                pp.goidcache -= _GoidCacheBatch - 1
                pp.goidcacheend = pp.goidcache + _GoidCacheBatch
        }
index e1788223e7ee630adcfde72a199009768424ba34..a9098b8100534b09f431ce96edd97bf0654051be 100644 (file)
@@ -759,7 +759,7 @@ type p struct {
 
 type schedt struct {
        // accessed atomically. keep at top to ensure alignment on 32-bit systems.
-       goidgen   uint64
+       goidgen   atomic.Uint64
        lastpoll  uint64 // time of last network poll, 0 if currently polling
        pollUntil uint64 // time to which current poll is sleeping