]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: hide sysExitTicks a little better
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 10 May 2023 21:06:54 +0000 (21:06 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 17 May 2023 14:53:01 +0000 (14:53 +0000)
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>
src/runtime/proc.go
src/runtime/trace.go

index c7bc08e2c0924ba76f7ed660b38a798e528dcc6e..363e8befe62c9f3d744d2165eae6c4855ab984a6 100644 (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++
index 8a2ef17f2bb36c83e293371f1fc494112e49860f..9c7792d42b81feff7a6e0546ea6072669dda82a0 100644 (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)