summaryrefslogtreecommitdiff
path: root/src/runtime/trace.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/trace.go')
-rw-r--r--src/runtime/trace.go85
1 files changed, 41 insertions, 44 deletions
diff --git a/src/runtime/trace.go b/src/runtime/trace.go
index 10436d80c2..9b12b42f11 100644
--- a/src/runtime/trace.go
+++ b/src/runtime/trace.go
@@ -232,14 +232,12 @@ func StartTrace() error {
// - or GoSysExit appears for a goroutine for which we don't emit EvGoInSyscall below.
// To instruct traceEvent that it must not ignore events below, we set startingtrace.
// trace.enabled is set afterwards once we have emitted all preliminary events.
- _g_ := getg()
- _g_.m.startingtrace = true
+ mp := getg().m
+ mp.startingtrace = true
// Obtain current stack ID to use in all traceEvGoCreate events below.
- mp := acquirem()
stkBuf := make([]uintptr, traceStackSize)
stackID := traceStackID(mp, stkBuf, 2)
- releasem(mp)
profBuf := newProfBuf(2, profBufWordCount, profBufTagCount) // after the timestamp, header is [pp.id, gp.goid]
trace.cpuLogRead = profBuf
@@ -293,7 +291,7 @@ func StartTrace() error {
trace.strings = make(map[string]uint64)
trace.seqGC = 0
- _g_.m.startingtrace = false
+ mp.startingtrace = false
trace.enabled = true
// Register runtime goroutine labels.
@@ -782,19 +780,18 @@ func traceReadCPU() {
}
func traceStackID(mp *m, buf []uintptr, skip int) uint64 {
- _g_ := getg()
- gp := mp.curg
+ gp := getg()
+ curgp := mp.curg
var nstk int
- if gp == _g_ {
+ if curgp == gp {
nstk = callers(skip+1, buf)
- } else if gp != nil {
- gp = mp.curg
- nstk = gcallers(gp, skip, buf)
+ } else if curgp != nil {
+ nstk = gcallers(curgp, skip, buf)
}
if nstk > 0 {
nstk-- // skip runtime.goexit
}
- if nstk > 0 && gp.goid == 1 {
+ if nstk > 0 && curgp.goid == 1 {
nstk-- // skip runtime.main
}
id := trace.stackTab.put(buf[:nstk])
@@ -1208,11 +1205,11 @@ func traceGCSTWDone() {
func traceGCSweepStart() {
// Delay the actual GCSweepStart event until the first span
// sweep. If we don't sweep anything, don't emit any events.
- _p_ := getg().m.p.ptr()
- if _p_.traceSweep {
+ pp := getg().m.p.ptr()
+ if pp.traceSweep {
throw("double traceGCSweepStart")
}
- _p_.traceSweep, _p_.traceSwept, _p_.traceReclaimed = true, 0, 0
+ pp.traceSweep, pp.traceSwept, pp.traceReclaimed = true, 0, 0
}
// traceGCSweepSpan traces the sweep of a single page.
@@ -1220,24 +1217,24 @@ func traceGCSweepStart() {
// This may be called outside a traceGCSweepStart/traceGCSweepDone
// pair; however, it will not emit any trace events in this case.
func traceGCSweepSpan(bytesSwept uintptr) {
- _p_ := getg().m.p.ptr()
- if _p_.traceSweep {
- if _p_.traceSwept == 0 {
+ pp := getg().m.p.ptr()
+ if pp.traceSweep {
+ if pp.traceSwept == 0 {
traceEvent(traceEvGCSweepStart, 1)
}
- _p_.traceSwept += bytesSwept
+ pp.traceSwept += bytesSwept
}
}
func traceGCSweepDone() {
- _p_ := getg().m.p.ptr()
- if !_p_.traceSweep {
+ pp := getg().m.p.ptr()
+ if !pp.traceSweep {
throw("missing traceGCSweepStart")
}
- if _p_.traceSwept != 0 {
- traceEvent(traceEvGCSweepDone, -1, uint64(_p_.traceSwept), uint64(_p_.traceReclaimed))
+ if pp.traceSwept != 0 {
+ traceEvent(traceEvGCSweepDone, -1, uint64(pp.traceSwept), uint64(pp.traceReclaimed))
}
- _p_.traceSweep = false
+ pp.traceSweep = false
}
func traceGCMarkAssistStart() {
@@ -1257,16 +1254,16 @@ func traceGoCreate(newg *g, pc uintptr) {
}
func traceGoStart() {
- _g_ := getg().m.curg
- _p_ := _g_.m.p
- _g_.traceseq++
- if _p_.ptr().gcMarkWorkerMode != gcMarkWorkerNotWorker {
- traceEvent(traceEvGoStartLabel, -1, uint64(_g_.goid), _g_.traceseq, trace.markWorkerLabels[_p_.ptr().gcMarkWorkerMode])
- } else if _g_.tracelastp == _p_ {
- traceEvent(traceEvGoStartLocal, -1, uint64(_g_.goid))
+ gp := getg().m.curg
+ pp := gp.m.p
+ gp.traceseq++
+ if pp.ptr().gcMarkWorkerMode != gcMarkWorkerNotWorker {
+ traceEvent(traceEvGoStartLabel, -1, uint64(gp.goid), gp.traceseq, trace.markWorkerLabels[pp.ptr().gcMarkWorkerMode])
+ } else if gp.tracelastp == pp {
+ traceEvent(traceEvGoStartLocal, -1, uint64(gp.goid))
} else {
- _g_.tracelastp = _p_
- traceEvent(traceEvGoStart, -1, uint64(_g_.goid), _g_.traceseq)
+ gp.tracelastp = pp
+ traceEvent(traceEvGoStart, -1, uint64(gp.goid), gp.traceseq)
}
}
@@ -1275,14 +1272,14 @@ func traceGoEnd() {
}
func traceGoSched() {
- _g_ := getg()
- _g_.tracelastp = _g_.m.p
+ gp := getg()
+ gp.tracelastp = gp.m.p
traceEvent(traceEvGoSched, 1)
}
func traceGoPreempt() {
- _g_ := getg()
- _g_.tracelastp = _g_.m.p
+ gp := getg()
+ gp.tracelastp = gp.m.p
traceEvent(traceEvGoPreempt, 1)
}
@@ -1294,12 +1291,12 @@ func traceGoPark(traceEv byte, skip int) {
}
func traceGoUnpark(gp *g, skip int) {
- _p_ := getg().m.p
+ pp := getg().m.p
gp.traceseq++
- if gp.tracelastp == _p_ {
+ if gp.tracelastp == pp {
traceEvent(traceEvGoUnblockLocal, skip, uint64(gp.goid))
} else {
- gp.tracelastp = _p_
+ gp.tracelastp = pp
traceEvent(traceEvGoUnblock, skip, uint64(gp.goid), gp.traceseq)
}
}
@@ -1321,10 +1318,10 @@ func traceGoSysExit(ts int64) {
// aka right now), and assign a fresh time stamp to keep the log consistent.
ts = 0
}
- _g_ := getg().m.curg
- _g_.traceseq++
- _g_.tracelastp = _g_.m.p
- traceEvent(traceEvGoSysExit, -1, uint64(_g_.goid), _g_.traceseq, uint64(ts)/traceTickDiv)
+ gp := getg().m.curg
+ gp.traceseq++
+ gp.tracelastp = gp.m.p
+ traceEvent(traceEvGoSysExit, -1, uint64(gp.goid), gp.traceseq, uint64(ts)/traceTickDiv)
}
func traceGoSysBlock(pp *p) {