diff options
| author | Ian Lance Taylor <iant@golang.org> | 2018-02-26 14:03:47 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2018-03-07 23:35:25 +0000 |
| commit | 419c06455a91c54a0552e1eb1565c397dd6fa763 (patch) | |
| tree | d849fa34ce017185a2d0f8fd96c0560dd65c8e71 /src/runtime/sys_linux_arm.s | |
| parent | c2f28de732749425ea29b5efa982c407964f8560 (diff) | |
| download | go-419c06455a91c54a0552e1eb1565c397dd6fa763.tar.xz | |
runtime: get traceback from VDSO code
Currently if a profiling signal arrives while executing within a VDSO
the profiler will report _ExternalCode, which is needlessly confusing
for a pure Go program. Change the VDSO calling code to record the
caller's PC/SP, so that we can do a traceback from that point. If that
fails for some reason, report _VDSO rather than _ExternalCode, which
should at least point in the right direction.
This adds some instructions to the code that calls the VDSO, but the
slowdown is reasonably negligible:
name old time/op new time/op delta
ClockVDSOAndFallbackPaths/vDSO-8 40.5ns ± 2% 41.3ns ± 1% +1.85% (p=0.002 n=10+10)
ClockVDSOAndFallbackPaths/Fallback-8 41.9ns ± 1% 43.5ns ± 1% +3.84% (p=0.000 n=9+9)
TimeNow-8 41.5ns ± 3% 41.5ns ± 2% ~ (p=0.723 n=10+10)
Fixes #24142
Change-Id: Iacd935db3c4c782150b3809aaa675a71799b1c9c
Reviewed-on: https://go-review.googlesource.com/97315
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/sys_linux_arm.s')
| -rw-r--r-- | src/runtime/sys_linux_arm.s | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s index 31923d36a4..4dd773adce 100644 --- a/src/runtime/sys_linux_arm.s +++ b/src/runtime/sys_linux_arm.s @@ -218,13 +218,18 @@ TEXT runtime·walltime(SB),NOSPLIT,$0-12 // Save old SP. Use R13 instead of SP to avoid linker rewriting the offsets. MOVW R13, R4 // R4 is unchanged by C code. - MOVW g_m(g), R1 - MOVW m_curg(R1), R0 + MOVW g_m(g), R5 // R5 is unchanged by C code. + + // Set vdsoPC and vdsoSP for SIGPROF traceback. + MOVW LR, m_vdsoPC(R5) + MOVW R13, m_vdsoSP(R5) + + MOVW m_curg(R5), R0 CMP g, R0 // Only switch if on curg. B.NE noswitch - MOVW m_g0(R1), R0 + MOVW m_g0(R5), R0 MOVW (g_sched+gobuf_sp)(R0), R13 // Set SP to g0 stack noswitch: @@ -249,9 +254,10 @@ finish: MOVW 12(R13), R2 // nsec MOVW R4, R13 // Restore real SP + MOVW $0, R1 + MOVW R1, m_vdsoSP(R5) MOVW R0, sec_lo+0(FP) - MOVW $0, R1 MOVW R1, sec_hi+4(FP) MOVW R2, nsec+8(FP) RET @@ -263,13 +269,18 @@ TEXT runtime·nanotime(SB),NOSPLIT,$0-8 // Save old SP. Use R13 instead of SP to avoid linker rewriting the offsets. MOVW R13, R4 // R4 is unchanged by C code. - MOVW g_m(g), R1 - MOVW m_curg(R1), R0 + MOVW g_m(g), R5 // R5 is unchanged by C code. + + // Set vdsoPC and vdsoSP for SIGPROF traceback. + MOVW LR, m_vdsoPC(R5) + MOVW R13, m_vdsoSP(R5) + + MOVW m_curg(R5), R0 CMP g, R0 // Only switch if on curg. B.NE noswitch - MOVW m_g0(R1), R0 + MOVW m_g0(R5), R0 MOVW (g_sched+gobuf_sp)(R0), R13 // Set SP to g0 stack noswitch: @@ -294,10 +305,11 @@ finish: MOVW 12(R13), R2 // nsec MOVW R4, R13 // Restore real SP + MOVW $0, R4 + MOVW R4, m_vdsoSP(R5) MOVW $1000000000, R3 MULLU R0, R3, (R1, R0) - MOVW $0, R4 ADD.S R2, R0 ADC R4, R1 |
