]> Cypherpunks repositories - gostls13.git/commit
runtime: always run semacquire on the G stack
authorKeith Randall <khr@golang.org>
Wed, 17 Sep 2014 00:26:16 +0000 (17:26 -0700)
committerKeith Randall <khr@golang.org>
Wed, 17 Sep 2014 00:26:16 +0000 (17:26 -0700)
commitda8cf5438aa676a99e8bb55c94011b2581743e1a
treec5ce0da4ace36faa3cae7e0a8f1891251cc0cfba
parente28746c44494030e9b44aa523cd5a21ebfe39ff5
runtime: always run semacquire on the G stack

semacquire might need to park the currently running G.  It can
only park if called from the G stack (because it has no way of
saving the M stack state).  So all calls to semacquire must come
from the G stack.

The three violators are GOMAXPROCS, ReadMemStats, and WriteHeapDump.
This change moves the semacquire call earlier, out of their C code
and into their Go code.

This seldom caused bugs because semacquire seldom actually had
to park the caller.  But it did happen intermittently.

Fixes #8749

LGTM=dvyukov
R=golang-codereviews, dvyukov, bradfitz
CC=golang-codereviews
https://golang.org/cl/144940043
src/runtime/debug.go
src/runtime/heapdump.c
src/runtime/mem.go
src/runtime/mgc0.c
src/runtime/proc.c
src/runtime/runtime.h
src/runtime/sema.go
src/runtime/stubs.go
src/runtime/thunk.s