]> Cypherpunks repositories - gostls13.git/commit
runtime: call rfork on scheduler stack on Plan 9
authorAnthony Martin <ality@pbrane.org>
Wed, 10 Sep 2014 00:19:01 +0000 (17:19 -0700)
committerAnthony Martin <ality@pbrane.org>
Wed, 10 Sep 2014 00:19:01 +0000 (17:19 -0700)
commit9f012e100210b6fb4e9bf8972e3d3b04c44b863a
tree901b94772beb07571198f04349d03d7c91bc43ad
parent1a5e394ab74672f59dd10623717fc3e08b17f0ab
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
src/runtime/os_plan9.c
src/runtime/os_plan9.go
src/runtime/os_plan9.h
src/runtime/proc.c
src/runtime/runtime.h
src/runtime/sys_plan9_386.s
src/runtime/sys_plan9_amd64.s