]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: factor our oneNewExtraM trace code
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 10 May 2023 03:14:22 +0000 (03:14 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 17 May 2023 14:43:25 +0000 (14:43 +0000)
In the interest of further cleaning up the trace.go API, move the trace
logic in oneNewExtraM into its own function.

Change-Id: I5cf478cb8cd0d301ee3b068347ed48ce768b8882
Reviewed-on: https://go-review.googlesource.com/c/go/+/494186
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/proc.go
src/runtime/trace.go

index 2c8750a5fefbfcc042fdbbcc899917f02601e0ef..b5e1c3e3b196efe01c944089987a0a4724c7b5f1 100644 (file)
@@ -2004,12 +2004,7 @@ func oneNewExtraM() {
                gp.racectx = racegostart(abi.FuncPCABIInternal(newextram) + sys.PCQuantum)
        }
        if traceEnabled() {
-               // Trigger two trace events for the locked g in the extra m,
-               // since the next event of the g will be traceEvGoSysExit in exitsyscall,
-               // while calling from C thread to Go.
-               traceGoCreate(gp, 0) // no start pc
-               gp.traceseq++
-               traceEvent(traceEvGoInSyscall, -1, gp.goid)
+               traceOneNewExtraM(gp)
        }
        // put on allg for garbage collector
        allgadd(gp)
index fd3ee273a383f584091ed95a21349ee13de478b0..27d58c22175fb555f249db9dc615029ee7d16f7a 100644 (file)
@@ -1713,3 +1713,16 @@ func startPCforTrace(pc uintptr) uintptr {
        }
        return f.datap.textAddr(*(*uint32)(w))
 }
+
+// traceOneNewExtraM registers the fact that a new extra M was created with
+// the tracer. This matters if the M (which has an attached G) is used while
+// the trace is still active because if it is, we need the fact that it exists
+// to show up in the final trace.
+func traceOneNewExtraM(gp *g) {
+       // Trigger two trace events for the locked g in the extra m,
+       // since the next event of the g will be traceEvGoSysExit in exitsyscall,
+       // while calling from C thread to Go.
+       traceGoCreate(gp, 0) // no start pc
+       gp.traceseq++
+       traceEvent(traceEvGoInSyscall, -1, gp.goid)
+}