]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: convert g.goid to uint64
authorMichael Pratt <mpratt@google.com>
Tue, 19 Jul 2022 17:49:33 +0000 (13:49 -0400)
committerMichael Pratt <mpratt@google.com>
Fri, 12 Aug 2022 01:39:28 +0000 (01:39 +0000)
schedt.goidgen and p.goidcache are already uint64, this makes all cases
consistent.

The only oddball here is schedtrace which prints -1 as an equivalent for
N/A or nil. A future CL will make this more explicit.

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

src/runtime/heapdump.go
src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/trace.go

index 543efeded4f52ddbb40bc03c3e7f5307918610e5..0601e38f2aa6aefd926963cde985aaba536e9022 100644 (file)
@@ -354,7 +354,7 @@ func dumpgoroutine(gp *g) {
        dumpint(tagGoroutine)
        dumpint(uint64(uintptr(unsafe.Pointer(gp))))
        dumpint(uint64(sp))
-       dumpint(uint64(gp.goid))
+       dumpint(gp.goid)
        dumpint(uint64(gp.gopc))
        dumpint(uint64(readgstatus(gp)))
        dumpbool(isSystemGoroutine(gp, false))
index d9df526f7ef4fec6fd1922b62b8c7c20ac3ad2f2..ff9caed2126870d41c508ae32c233803f3eee53c 100644 (file)
@@ -1919,7 +1919,7 @@ func oneNewExtraM() {
        mp.lockedInt++
        mp.lockedg.set(gp)
        gp.lockedm.set(mp)
-       gp.goid = int64(sched.goidgen.Add(1))
+       gp.goid = sched.goidgen.Add(1)
        if raceenabled {
                gp.racectx = racegostart(abi.FuncPCABIInternal(newextram) + sys.PCQuantum)
        }
@@ -4172,7 +4172,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
                pp.goidcache -= _GoidCacheBatch - 1
                pp.goidcacheend = pp.goidcache + _GoidCacheBatch
        }
-       newg.goid = int64(pp.goidcache)
+       newg.goid = pp.goidcache
        pp.goidcache++
        if raceenabled {
                newg.racectx = racegostart(callerpc)
@@ -5455,11 +5455,11 @@ func schedtrace(detailed bool) {
                }
                id2 := int64(-1)
                if gp != nil {
-                       id2 = gp.goid
+                       id2 = int64(gp.goid)
                }
                id3 := int64(-1)
                if lockedg != nil {
-                       id3 = lockedg.goid
+                       id3 = int64(lockedg.goid)
                }
                print("  M", mp.id, ": p=", id1, " curg=", id2, " mallocing=", mp.mallocing, " throwing=", mp.throwing, " preemptoff=", mp.preemptoff, " locks=", mp.locks, " dying=", mp.dying, " spinning=", mp.spinning, " blocked=", mp.blocked, " lockedg=", id3, "\n")
        }
@@ -6274,7 +6274,7 @@ var inittrace tracestat
 
 type tracestat struct {
        active bool   // init tracing activation status
-       id     int64  // init goroutine id
+       id     uint64 // init goroutine id
        allocs uint64 // heap allocations
        bytes  uint64 // heap allocated bytes
 }
index a9098b8100534b09f431ce96edd97bf0654051be..78a089ec9dbd809a3251ad2fd6e526095623975f 100644 (file)
@@ -437,7 +437,7 @@ type g struct {
        param        unsafe.Pointer
        atomicstatus uint32
        stackLock    uint32 // sigprof/scang lock; TODO: fold in to atomicstatus
-       goid         int64
+       goid         uint64
        schedlink    guintptr
        waitsince    int64      // approx time when the g become blocked
        waitreason   waitReason // if status==Gwaiting
@@ -1011,7 +1011,7 @@ type stkframe struct {
 // ancestorInfo records details of where a goroutine was started.
 type ancestorInfo struct {
        pcs  []uintptr // pcs from the stack of this goroutine
-       goid int64     // goroutine id of this goroutine; original goroutine possibly dead
+       goid uint64    // goroutine id of this goroutine; original goroutine possibly dead
        gopc uintptr   // pc of go statement that created this goroutine
 }
 
index 4290d9224082404dcf66c181f8826bda06b69f93..0bae0db88d38443c411b80e4532d254070348e6c 100644 (file)
@@ -262,16 +262,16 @@ func StartTrace() error {
                        gp.tracelastp = getg().m.p
                        // +PCQuantum because traceFrameForPC expects return PCs and subtracts PCQuantum.
                        id := trace.stackTab.put([]uintptr{startPCforTrace(gp.startpc) + sys.PCQuantum})
-                       traceEvent(traceEvGoCreate, -1, uint64(gp.goid), uint64(id), stackID)
+                       traceEvent(traceEvGoCreate, -1, gp.goid, uint64(id), stackID)
                }
                if status == _Gwaiting {
                        // traceEvGoWaiting is implied to have seq=1.
                        gp.traceseq++
-                       traceEvent(traceEvGoWaiting, -1, uint64(gp.goid))
+                       traceEvent(traceEvGoWaiting, -1, gp.goid)
                }
                if status == _Gsyscall {
                        gp.traceseq++
-                       traceEvent(traceEvGoInSyscall, -1, uint64(gp.goid))
+                       traceEvent(traceEvGoInSyscall, -1, gp.goid)
                } else {
                        gp.sysblocktraced = false
                }
@@ -780,7 +780,7 @@ func traceCPUSample(gp *g, pp *p, stk []uintptr) {
                hdr[0] = 0b10
        }
        if gp != nil {
-               hdr[1] = uint64(gp.goid)
+               hdr[1] = gp.goid
        }
 
        // Allow only one writer at a time
@@ -1376,7 +1376,7 @@ func traceGoCreate(newg *g, pc uintptr) {
        newg.tracelastp = getg().m.p
        // +PCQuantum because traceFrameForPC expects return PCs and subtracts PCQuantum.
        id := trace.stackTab.put([]uintptr{startPCforTrace(pc) + sys.PCQuantum})
-       traceEvent(traceEvGoCreate, 2, uint64(newg.goid), uint64(id))
+       traceEvent(traceEvGoCreate, 2, newg.goid, uint64(id))
 }
 
 func traceGoStart() {
@@ -1384,12 +1384,12 @@ func traceGoStart() {
        pp := gp.m.p
        gp.traceseq++
        if pp.ptr().gcMarkWorkerMode != gcMarkWorkerNotWorker {
-               traceEvent(traceEvGoStartLabel, -1, uint64(gp.goid), gp.traceseq, trace.markWorkerLabels[pp.ptr().gcMarkWorkerMode])
+               traceEvent(traceEvGoStartLabel, -1, gp.goid, gp.traceseq, trace.markWorkerLabels[pp.ptr().gcMarkWorkerMode])
        } else if gp.tracelastp == pp {
-               traceEvent(traceEvGoStartLocal, -1, uint64(gp.goid))
+               traceEvent(traceEvGoStartLocal, -1, gp.goid)
        } else {
                gp.tracelastp = pp
-               traceEvent(traceEvGoStart, -1, uint64(gp.goid), gp.traceseq)
+               traceEvent(traceEvGoStart, -1, gp.goid, gp.traceseq)
        }
 }
 
@@ -1420,10 +1420,10 @@ func traceGoUnpark(gp *g, skip int) {
        pp := getg().m.p
        gp.traceseq++
        if gp.tracelastp == pp {
-               traceEvent(traceEvGoUnblockLocal, skip, uint64(gp.goid))
+               traceEvent(traceEvGoUnblockLocal, skip, gp.goid)
        } else {
                gp.tracelastp = pp
-               traceEvent(traceEvGoUnblock, skip, uint64(gp.goid), gp.traceseq)
+               traceEvent(traceEvGoUnblock, skip, gp.goid, gp.traceseq)
        }
 }
 
@@ -1447,7 +1447,7 @@ func traceGoSysExit(ts int64) {
        gp := getg().m.curg
        gp.traceseq++
        gp.tracelastp = gp.m.p
-       traceEvent(traceEvGoSysExit, -1, uint64(gp.goid), gp.traceseq, uint64(ts)/traceTickDiv)
+       traceEvent(traceEvGoSysExit, -1, gp.goid, gp.traceseq, uint64(ts)/traceTickDiv)
 }
 
 func traceGoSysBlock(pp *p) {