From 00cb841b83ad157bc21d36daf0626bbcd4af0d57 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Tue, 7 May 2019 17:56:49 +1000 Subject: syscall: implement rawVforkSyscall for remaining linux platforms This allows the use of CLONE_VFORK and CLONE_VM for fork/exec, preventing 'fork/exec ...: cannot allocate memory' failures from occuring when attempting to execute commands from a Go process that has a large memory footprint. Additionally, this should reduce the latency of fork/exec on these platforms. Fixes #31936 Change-Id: I4e28cf0763173145cacaa5340680dca9ff449305 Reviewed-on: https://go-review.googlesource.com/c/go/+/295849 Trust: Joel Sing Run-TryBot: Joel Sing Reviewed-by: Cherry Zhang --- src/syscall/asm_linux_arm.s | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/syscall/asm_linux_arm.s') diff --git a/src/syscall/asm_linux_arm.s b/src/syscall/asm_linux_arm.s index 458e9cce79..6bb4df81a0 100644 --- a/src/syscall/asm_linux_arm.s +++ b/src/syscall/asm_linux_arm.s @@ -154,6 +154,27 @@ ok1: MOVW R0, err+24(FP) RET +// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr) +TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-16 + MOVW trap+0(FP), R7 // syscall entry + MOVW a1+4(FP), R0 + MOVW $0, R1 + MOVW $0, R2 + SWI $0 + MOVW $0xfffff001, R1 + CMP R1, R0 + BLS ok + MOVW $-1, R1 + MOVW R1, r1+8(FP) + RSB $0, R0, R0 + MOVW R0, err+12(FP) + RET +ok: + MOVW R0, r1+8(FP) + MOVW $0, R0 + MOVW R0, err+12(FP) + RET + // func rawSyscallNoError(trap uintptr, a1, a2, a3 uintptr) (r1, r2 uintptr); TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-24 MOVW trap+0(FP), R7 // syscall entry -- cgit v1.3-5-g9baa