aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/asm_linux_386.s
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2019-05-07 17:56:49 +1000
committerJoel Sing <joel@sing.id.au>2021-03-03 05:33:21 +0000
commit00cb841b83ad157bc21d36daf0626bbcd4af0d57 (patch)
tree10d3c992346b69236eb1356bfd381cc5e4f49584 /src/syscall/asm_linux_386.s
parentf2df1e3c34ceb2225d0df5c9ec92d5dc9e9ba919 (diff)
downloadgo-00cb841b83ad157bc21d36daf0626bbcd4af0d57.tar.xz
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 <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/syscall/asm_linux_386.s')
-rw-r--r--src/syscall/asm_linux_386.s20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s
index 4201f367ba..1c69083118 100644
--- a/src/syscall/asm_linux_386.s
+++ b/src/syscall/asm_linux_386.s
@@ -110,6 +110,26 @@ ok2:
MOVL $0, err+36(FP)
RET
+// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
+TEXT ·rawVforkSyscall(SB),NOSPLIT|NOFRAME,$0-16
+ MOVL trap+0(FP), AX // syscall entry
+ MOVL a1+4(FP), BX
+ MOVL $0, CX
+ MOVL $0, DX
+ POPL SI // preserve return address
+ INVOKE_SYSCALL
+ PUSHL SI
+ CMPL AX, $0xfffff001
+ JLS ok
+ MOVL $-1, r1+8(FP)
+ NEGL AX
+ MOVL AX, err+12(FP)
+ RET
+ok:
+ MOVL AX, r1+8(FP)
+ MOVL $0, err+12(FP)
+ RET
+
// func rawSyscallNoError(trap uintptr, a1, a2, a3 uintptr) (r1, r2 uintptr);
TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-24
MOVL trap+0(FP), AX // syscall entry