From 6b7206feb2df3116bd5c471813353ffec1ff25fe Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Tue, 2 Dec 2025 19:46:39 +0000 Subject: [PATCH] runtime: remove logical stack sentinel for runtime lock stacks When CL 533258 added frame pointer support for the block and mutex profiles, it deferred skipping/inline expansion, similar to the execution tracer. The first frame indicated whether this expansion was needed by holding either the number of frames to skip (implying inline expansion) or the logicalStackSentinel placeholder to indicate that no extra handling is needed. However, CL 598515 switched to doing the skipping/inline expansion at sample time. After this, the sentinel value is unused. This CL removes the sentinel from runtime lock profiling, correcting an oversight from that CL. This didn't cause any problems since post-processing would just ignore the bogus sentinel value; this is just a cleanup. Change-Id: Idbec11f57ac7a57426cd8a064782c4fe6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/726040 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Reviewed-by: Carlos Amedee --- src/runtime/mprof.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index 7d761720b5..0452b1b605 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -731,8 +731,6 @@ func (prof *mLockProfile) captureStack() { } prof.haveStack = true - prof.stack[0] = logicalStackSentinel - var nstk int gp := getg() sp := sys.GetCallerSP() @@ -740,7 +738,7 @@ func (prof *mLockProfile) captureStack() { systemstack(func() { var u unwinder u.initAt(pc, sp, 0, gp, unwindSilentErrors|unwindJumpStack) - nstk = 1 + tracebackPCs(&u, skip, prof.stack[1:]) + nstk = tracebackPCs(&u, skip, prof.stack) }) if nstk < len(prof.stack) { prof.stack[nstk] = 0 @@ -782,7 +780,6 @@ func (prof *mLockProfile) storeSlow() { saveBlockEventStack(cycles, rate, prof.stack[:nstk], mutexProfile) if lost > 0 { lostStk := [...]uintptr{ - logicalStackSentinel, abi.FuncPCABIInternal(_LostContendedRuntimeLock) + sys.PCQuantum, } saveBlockEventStack(lost, rate, lostStk[:], mutexProfile) -- 2.52.0