From 150b728675c64addd24d79ad3bb68fec4c137940 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 14 Feb 2018 14:51:39 -0500 Subject: runtime: use native CAS and memory barrier on ARMv7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gets us around the kernel helpers on ARMv7. It is slightly faster than using the kernel helper. name old time/op new time/op delta AtomicLoad-4 72.5ns ± 0% 69.5ns ± 0% -4.08% (p=0.000 n=9+9) AtomicStore-4 57.6ns ± 1% 54.4ns ± 0% -5.58% (p=0.000 n=10+9) [Geo mean] 64.6ns 61.5ns -4.83% If performance is really critical, we can even do compiler intrinsics on GOARM=7. Fixes #23792. Change-Id: I36497d880890b26bdf01e048b542bd5fd7b17d23 Reviewed-on: https://go-review.googlesource.com/94076 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements --- src/runtime/sys_linux_arm.s | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/runtime/sys_linux_arm.s') diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s index fc9dc9bbb8..aa39732cfb 100644 --- a/src/runtime/sys_linux_arm.s +++ b/src/runtime/sys_linux_arm.s @@ -489,13 +489,18 @@ TEXT runtime·usleep(SB),NOSPLIT,$12 // even on single-core devices. The kernel helper takes care of all of // this for us. -TEXT publicationBarrier<>(SB),NOSPLIT,$0 +TEXT kernelPublicationBarrier<>(SB),NOSPLIT,$0 // void __kuser_memory_barrier(void); - MOVW $0xffff0fa0, R15 // R15 is hardware PC. + MOVW $0xffff0fa0, R11 + CALL (R11) + RET TEXT ·publicationBarrier(SB),NOSPLIT,$0 - BL publicationBarrier<>(SB) - RET + MOVB ·goarm(SB), R11 + CMP $7, R11 + BLT 2(PC) + JMP ·armPublicationBarrier(SB) + JMP kernelPublicationBarrier<>(SB) // extra layer so this function is leaf and no SP adjustment on GOARM=7 TEXT runtime·osyield(SB),NOSPLIT,$0 MOVW $SYS_sched_yield, R7 -- cgit v1.3-5-g9baa