]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't use systemstack for BeforeFork/AfterFork
authorIan Lance Taylor <iant@golang.org>
Wed, 11 Aug 2021 22:34:29 +0000 (15:34 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 13 Aug 2021 20:50:48 +0000 (20:50 +0000)
In https://golang.org/cl/140930043 syscall.BeforeFork was changed to
call beforefork via onM. This was done because at the time BeforeFork
was written in C but was called from Go. While the runtime was being
converted to Go, calls to complex C functions used onM to ensure that
enough stack space was available.

In https://golang.org/cl/172260043 the syscall.BeforeFork and
beforefork functions were rewritten into Go. In this rewrite
syscall.BeforeFork continue to call beforefork via onM, although
because both functions were now in Go that was no longer necessary.

In https://golang.org/cl/174950043 onM was renamed to systemstack,
producing essentially the code we have today.

Therefore, the use of systemstack in syscall.BeforeFork (and
syscall.AfterFork) is a historical relic.  Remove it.

Change-Id: Ia570f556b20e8405afa6c5e707bd6f4ad18fd7ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/341335
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/proc.go

index 764f12769ed9f498ae2e0740b5f2792768d6bf15..cde1a115830faacba3c71ba2c75184849457feb1 100644 (file)
@@ -4104,7 +4104,10 @@ func exitsyscall0(gp *g) {
        schedule() // Never returns.
 }
 
-func beforefork() {
+// Called from syscall package before fork.
+//go:linkname syscall_runtime_BeforeFork syscall.runtime_BeforeFork
+//go:nosplit
+func syscall_runtime_BeforeFork() {
        gp := getg().m.curg
 
        // Block signals during a fork, so that the child does not run
@@ -4121,14 +4124,10 @@ func beforefork() {
        gp.stackguard0 = stackFork
 }
 
-// Called from syscall package before fork.
-//go:linkname syscall_runtime_BeforeFork syscall.runtime_BeforeFork
+// Called from syscall package after fork in parent.
+//go:linkname syscall_runtime_AfterFork syscall.runtime_AfterFork
 //go:nosplit
-func syscall_runtime_BeforeFork() {
-       systemstack(beforefork)
-}
-
-func afterfork() {
+func syscall_runtime_AfterFork() {
        gp := getg().m.curg
 
        // See the comments in beforefork.
@@ -4139,13 +4138,6 @@ func afterfork() {
        gp.m.locks--
 }
 
-// Called from syscall package after fork in parent.
-//go:linkname syscall_runtime_AfterFork syscall.runtime_AfterFork
-//go:nosplit
-func syscall_runtime_AfterFork() {
-       systemstack(afterfork)
-}
-
 // inForkedChild is true while manipulating signals in the child process.
 // This is used to avoid calling libc functions in case we are using vfork.
 var inForkedChild bool