From a2737b1aab2d351792291c5967147220f9327dc4 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 9 May 2023 19:48:29 +0000 Subject: [PATCH] runtime: hide trace lock init details This change is in service of hiding more execution trace implementation details for big changes to come. Change-Id: I49b9716a7bf285d23c86b58912a05eff4ddc2213 Reviewed-on: https://go-review.googlesource.com/c/go/+/494182 Reviewed-by: Michael Pratt Run-TryBot: Michael Knyszek Auto-Submit: Michael Knyszek TryBot-Result: Gopher Robot --- src/runtime/proc.go | 5 +---- src/runtime/trace.go | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index db4eb21cb85..4fb4595a50c 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -691,11 +691,8 @@ func schedinit() { lockInit(&allpLock, lockRankAllp) lockInit(&reflectOffs.lock, lockRankReflectOffs) lockInit(&finlock, lockRankFin) - lockInit(&trace.bufLock, lockRankTraceBuf) - lockInit(&trace.stringsLock, lockRankTraceStrings) - lockInit(&trace.lock, lockRankTrace) lockInit(&cpuprof.lock, lockRankCpuprof) - lockInit(&trace.stackTab.lock, lockRankTraceStackTab) + traceLockInit() // Enforce that this lock is always a leaf lock. // All of this lock's critical sections should be // extremely short. diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 5eb68271d10..860b53bdbb9 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -168,6 +168,14 @@ var trace struct { buf traceBufPtr // global trace buffer, used when running without a p } +// traceLockInit initializes global trace locks. +func traceLockInit() { + lockInit(&trace.bufLock, lockRankTraceBuf) + lockInit(&trace.stringsLock, lockRankTraceStrings) + lockInit(&trace.lock, lockRankTrace) + lockInit(&trace.stackTab.lock, lockRankTraceStackTab) +} + // traceBufHeader is per-P tracing buffer. type traceBufHeader struct { link traceBufPtr // in trace.empty/full