aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-08-11 15:34:29 -0700
committerIan Lance Taylor <iant@golang.org>2021-08-13 20:50:48 +0000
commit2eb4d68833e28fce2701a9c39755413630921371 (patch)
tree963384e32e1508c78ba208d542f1bb1319acb25f /src/runtime/proc.go
parentbad1fc126536f14fd6f00a93e1b76320c1510bf2 (diff)
downloadgo-2eb4d68833e28fce2701a9c39755413630921371.tar.gz
go-2eb4d68833e28fce2701a9c39755413630921371.zip
runtime: don't use systemstack for BeforeFork/AfterFork
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>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 764f12769e..cde1a11583 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -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