1
0
mirror of https://github.com/golang/go synced 2024-11-17 00:14:50 -07:00

runtime: hide sysExitTicks a little better

Just another step to hiding implementation details.

Change-Id: I71b7cc522d18c23f03a9bf32e428279e62b39a89
Reviewed-on: https://go-review.googlesource.com/c/go/+/494192
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Anthony Knyszek 2023-05-10 21:06:54 +00:00 committed by Gopher Robot
parent 87e69c1812
commit e3ada56537
2 changed files with 10 additions and 9 deletions

View File

@ -2706,7 +2706,7 @@ func execute(gp *g, inheritTime bool) {
// GoSysExit has to happen when we have a P, but before GoStart.
// So we emit it here.
if gp.syscallsp != 0 && gp.trace.sysBlockTraced {
traceGoSysExit(gp.trace.sysExitTicks)
traceGoSysExit()
}
traceGoStart()
}
@ -4024,7 +4024,6 @@ func exitsyscall() {
return
}
gp.trace.sysExitTicks = 0
if traceEnabled() {
// Wait till traceGoSysBlock event is emitted.
// This ensures consistency of the trace (the goroutine is started after it is blocked).
@ -4084,7 +4083,7 @@ func exitsyscallfast(oldp *p) bool {
osyield()
}
}
traceGoSysExit(0)
traceGoSysExit()
}
})
if ok {
@ -4110,7 +4109,7 @@ func exitsyscallfast_reacquired() {
// Denote blocking of the new syscall.
traceGoSysBlock(gp.m.p.ptr())
// Denote completion of the current syscall.
traceGoSysExit(0)
traceGoSysExit()
})
}
gp.m.p.ptr().syscalltick++

View File

@ -329,7 +329,7 @@ func StartTrace() error {
traceGoStart()
// Note: ticksStart needs to be set after we emit traceEvGoInSyscall events.
// If we do it the other way around, it is possible that exitsyscall will
// query sysexitticks after ticksStart but before traceEvGoInSyscall timestamp.
// query sysExitTicks after ticksStart but before traceEvGoInSyscall timestamp.
// It will lead to a false conclusion that cputicks is broken.
trace.ticksStart = cputicks()
trace.timeStart = nanotime()
@ -1606,12 +1606,14 @@ func traceGoSysCall() {
traceEvent(traceEvGoSysCall, skip)
}
func traceGoSysExit(ts int64) {
func traceGoSysExit() {
gp := getg().m.curg
ts := gp.trace.sysExitTicks
if ts != 0 && ts < trace.ticksStart {
// There is a race between the code that initializes sysexitticks
// There is a race between the code that initializes sysExitTicks
// (in exitsyscall, which runs without a P, and therefore is not
// stopped with the rest of the world) and the code that initializes
// a new trace. The recorded sysexitticks must therefore be treated
// a new trace. The recorded sysExitTicks must therefore be treated
// as "best effort". If they are valid for this trace, then great,
// use them for greater accuracy. But if they're not valid for this
// trace, assume that the trace was started after the actual syscall
@ -1619,7 +1621,7 @@ func traceGoSysExit(ts int64) {
// aka right now), and assign a fresh time stamp to keep the log consistent.
ts = 0
}
gp := getg().m.curg
gp.trace.sysExitTicks = 0
gp.trace.seq++
gp.trace.lastP = gp.m.p
traceEvent(traceEvGoSysExit, -1, gp.goid, gp.trace.seq, uint64(ts)/traceTickDiv)