diff options
author | Anthony Martin <ality@pbrane.org> | 2014-09-09 17:19:01 -0700 |
---|---|---|
committer | Anthony Martin <ality@pbrane.org> | 2014-09-09 17:19:01 -0700 |
commit | 9f012e100210b6fb4e9bf8972e3d3b04c44b863a (patch) | |
tree | 901b94772beb07571198f04349d03d7c91bc43ad /src/runtime/os_plan9.go | |
parent | 1a5e394ab74672f59dd10623717fc3e08b17f0ab (diff) | |
download | go-9f012e100210b6fb4e9bf8972e3d3b04c44b863a.tar.gz go-9f012e100210b6fb4e9bf8972e3d3b04c44b863a.zip |
runtime: call rfork on scheduler stack on Plan 9
A race exists between the parent and child processes after a fork.
The child needs to access the new M pointer passed as an argument
but the parent may have already returned and clobbered it.
Previously, we avoided this by saving the necessary data into
registers before the rfork system call but this isn't guaranteed
to work because Plan 9 makes no promises about the register state
after a system call. Only the 386 kernel seems to save them.
For amd64 and arm, this method won't work.
We eliminate the race by allocating stack space for the scheduler
goroutines (g0) in the per-process copy-on-write stack segment and
by only calling rfork on the scheduler stack.
LGTM=aram, 0intro, rsc
R=aram, 0intro, mischief, rsc
CC=golang-codereviews
https://golang.org/cl/110680044
Diffstat (limited to 'src/runtime/os_plan9.go')
-rw-r--r-- | src/runtime/os_plan9.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/runtime/os_plan9.go b/src/runtime/os_plan9.go index 09cb3d93ff..c7b5bf7050 100644 --- a/src/runtime/os_plan9.go +++ b/src/runtime/os_plan9.go @@ -12,7 +12,7 @@ func seek(fd int32, offset int64, whence int32) int64 func exits(msg *byte) func brk_(addr unsafe.Pointer) uintptr func sleep(ms int32) int32 -func rfork(flags int32, stk, mm, gg, fn unsafe.Pointer) int32 +func rfork(flags int32) int32 func plan9_semacquire(addr *uint32, block int32) int32 func plan9_tsemacquire(addr *uint32, ms int32) int32 func plan9_semrelease(addr *uint32, count int32) int32 @@ -21,6 +21,7 @@ func noted(mode int32) int32 func nsec(*int64) int64 func sigtramp(ureg, msg unsafe.Pointer) func setfpmasks() +func tstart_plan9(newm *m) func errstr() string // The size of the note handler frame varies among architectures, |