diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2023-05-10 21:06:54 +0000 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-05-17 14:53:01 +0000 |
commit | e3ada56537e0fdf04111de01a336902b1e0fb9ab (patch) | |
tree | 6ceaa5506dc03b55094327aa3cda10c54655f65b | |
parent | 87e69c1812c2197688e0d14720760ea87b3b26af (diff) | |
download | go-git-e3ada56537e0fdf04111de01a336902b1e0fb9ab.tar.gz |
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>
-rw-r--r-- | src/runtime/proc.go | 7 | ||||
-rw-r--r-- | src/runtime/trace.go | 12 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index c7bc08e2c0..363e8befe6 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -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++ diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 8a2ef17f2b..9c7792d42b 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -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) |