From 0a7c7ac80e7c4ccd2b04b6b65100794adbd72ba5 Mon Sep 17 00:00:00 2001 From: Rick Hudson Date: Wed, 27 Aug 2014 11:15:47 -0400 Subject: runtime: changes to g->atomicstatus (nee status) to support concurrent GC Every change to g->atomicstatus is now done atomically so that we can ensure that all gs pass through a gc safepoint on demand. This allows the GC to move from one phase to the next safely. In some phases the stack will be scanned. This CL only deals with the infrastructure that allows g->atomicstatus to go from one state to another. Future CLs will deal with scanning and monitoring what phase the GC is in. The major change was to moving to using a Gscan bit to indicate that the status is in a scan state. The only bug fix was in oldstack where I wasn't moving to a Gcopystack state in order to block scanning until the new stack was in place. The proc.go file is waiting for an atomic load instruction. LGTM=rsc R=golang-codereviews, dvyukov, josharian, rsc CC=golang-codereviews, khr https://golang.org/cl/132960044 --- src/pkg/runtime/panic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pkg/runtime/panic.c') diff --git a/src/pkg/runtime/panic.c b/src/pkg/runtime/panic.c index d0284f9c20..dc3d2e93bf 100644 --- a/src/pkg/runtime/panic.c +++ b/src/pkg/runtime/panic.c @@ -477,6 +477,7 @@ bool runtime·canpanic(G *gp) { M *m; + uint32 status; // Note that g is m->gsignal, different from gp. // Note also that g->m can change at preemption, so m can go stale @@ -490,7 +491,8 @@ runtime·canpanic(G *gp) return false; if(m->locks-m->softfloat != 0 || m->mallocing != 0 || m->throwing != 0 || m->gcing != 0 || m->dying != 0) return false; - if(gp->status != Grunning || gp->syscallsp != 0) + status = runtime·readgstatus(gp); + if((status&~Gscan) != Grunning || gp->syscallsp != 0) return false; #ifdef GOOS_windows if(m->libcallsp != 0) -- cgit v1.3-5-g9baa