mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: make systemstack tail call if already switched
Currently systemstack always calls its argument, even if we're already on the system stack. Unfortunately, traceback with _TraceJump stops at the first systemstack it sees, which often cuts off runtime stacks early in profiles. Fix this by performing a tail call if we're already on the system stack. This eliminates it from the traceback entirely, so it won't stop prematurely (or all get mushed into a single node in the profile graph). Change-Id: Ibc69e8765e899f8d3806078517b8c7314da196f4 Reviewed-on: https://go-review.googlesource.com/74050 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
67a7d5d885
commit
15d6ab69fb
11 changed files with 83 additions and 18 deletions
|
|
@ -395,3 +395,16 @@ func LockOSCounts() (external, internal uint32) {
|
|||
}
|
||||
return g.m.lockedExt, g.m.lockedInt
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func TracebackSystemstack(stk []uintptr, i int) int {
|
||||
if i == 0 {
|
||||
pc, sp := getcallerpc(), getcallersp(unsafe.Pointer(&stk))
|
||||
return gentraceback(pc, sp, 0, getg(), 0, &stk[0], len(stk), nil, nil, _TraceJumpStack)
|
||||
}
|
||||
n := 0
|
||||
systemstack(func() {
|
||||
n = TracebackSystemstack(stk, i-1)
|
||||
})
|
||||
return n
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue