aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/stack1.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-01-30 15:30:41 -0500
committerAustin Clements <austin@google.com>2015-02-02 19:34:51 +0000
commit28b51184156e1261bb92e7ec4050a794dd606fa6 (patch)
tree8d8659e3e706f687b241e8068ef80ff80987c3d2 /src/runtime/stack1.go
parentf95becaddb539a45cc9bedbbbc9ee4a2433c1ab5 (diff)
downloadgo-28b51184156e1261bb92e7ec4050a794dd606fa6.tar.xz
runtime: rename m.gcing to m.preemptoff and make it a string
m.gcing has become overloaded to mean "don't preempt this g" in general. Once the garbage collector is preemptible, the one thing it *won't* mean is that we're in the garbage collector. So, rename gcing to "preemptoff" and make it a string giving a reason that preemption is disabled. gcing was never set to anything but 0 or 1, so we don't have to worry about there being a stack of reasons. Change-Id: I4337c29e8e942e7aa4f106fc29597e1b5de4ef46 Reviewed-on: https://go-review.googlesource.com/3660 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/stack1.go')
-rw-r--r--src/runtime/stack1.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/runtime/stack1.go b/src/runtime/stack1.go
index dda39ce481..8ad331777c 100644
--- a/src/runtime/stack1.go
+++ b/src/runtime/stack1.go
@@ -208,7 +208,7 @@ func stackalloc(n uint32) stack {
}
var x gclinkptr
c := thisg.m.mcache
- if c == nil || thisg.m.gcing != 0 || thisg.m.helpgc != 0 {
+ if c == nil || thisg.m.preemptoff != "" || thisg.m.helpgc != 0 {
// c == nil can happen in the guts of exitsyscall or
// procresize. Just get a stack from the global pool.
// Also don't touch stackcache during gc
@@ -271,7 +271,7 @@ func stackfree(stk stack) {
}
x := gclinkptr(v)
c := gp.m.mcache
- if c == nil || gp.m.gcing != 0 || gp.m.helpgc != 0 {
+ if c == nil || gp.m.preemptoff != "" || gp.m.helpgc != 0 {
lock(&stackpoolmu)
stackpoolfree(x, order)
unlock(&stackpoolmu)
@@ -648,7 +648,8 @@ func newstack() {
// Be conservative about where we preempt.
// We are interested in preempting user Go code, not runtime code.
- // If we're holding locks, mallocing, or GCing, don't preempt.
+ // If we're holding locks, mallocing, or preemption is disabled, don't
+ // preempt.
// This check is very early in newstack so that even the status change
// from Grunning to Gwaiting and back doesn't happen in this case.
// That status change by itself can be viewed as a small preemption,
@@ -658,7 +659,7 @@ func newstack() {
// it needs a lock held by the goroutine), that small preemption turns
// into a real deadlock.
if preempt {
- if thisg.m.locks != 0 || thisg.m.mallocing != 0 || thisg.m.gcing != 0 || thisg.m.p.status != _Prunning {
+ if thisg.m.locks != 0 || thisg.m.mallocing != 0 || thisg.m.preemptoff != "" || thisg.m.p.status != _Prunning {
// Let the goroutine keep running for now.
// gp->preempt is set, so it will be preempted next time.
gp.stackguard0 = gp.stack.lo + _StackGuard