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/runtime.h | |
| parent | 1a5e394ab74672f59dd10623717fc3e08b17f0ab (diff) | |
| download | go-9f012e100210b6fb4e9bf8972e3d3b04c44b863a.tar.xz | |
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/runtime.h')
| -rw-r--r-- | src/runtime/runtime.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 4622a2c3d7..da9b2b7514 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -522,6 +522,15 @@ enum { Solaris = 0 }; #endif +#ifdef GOOS_plan9 +enum { + Plan9 = 1 +}; +#else +enum { + Plan9 = 0 +}; +#endif // Lock-free stack node. struct LFNode |
