aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-05 15:02:09 -0500
committerRuss Cox <rsc@golang.org>2015-01-06 15:10:13 +0000
commit02f89331c2ec09923806611bc1a8fbb2ffcbcca5 (patch)
treee0fedd0eafa998ad158c15f6096f18dfdc4c4d93 /src/runtime/malloc.go
parentff979626fc14eb0debcce44494ca114879de618d (diff)
downloadgo-02f89331c2ec09923806611bc1a8fbb2ffcbcca5.tar.xz
runtime: fix two garbage collector bugs
First, call clearcheckmarks immediately after changing checkmark, so that there is less time when the checkmark flag and the bitmap are inconsistent. The tiny gap between the two lines is fine, because the world is stopped. Before, the gap was much larger and included such code as "go bgsweep()", which allocated. Second, modify gcphase only when the world is stopped. As written, gcscan_m was changing gcphase from 0 to GCscan and back to 0 while other goroutines were running. Another goroutine running at the same time might decide to sleep, see GCscan, call gcphasework, and start "helping" by scanning its stack. That's fine, except that if gcphase flips back to 0 as the goroutine calls scanblock, it will start draining the work buffers prematurely. Both of these were found wbshadow=2 (and a lot of hard work). Eventually that will run automatically, but right now it still doesn't quite work for all.bash, due to mmap conflicts with pthread-created threads. Change-Id: I99aa8210cff9c6e7d0a1b62c75be32a23321897b Reviewed-on: https://go-review.googlesource.com/2340 Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 22c0dfe3a4..772d3309d2 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -493,6 +493,7 @@ func gogc(force int32) {
systemstack(stoptheworld)
systemstack(finishsweep_m) // finish sweep before we start concurrent scan.
if force == 0 { // Do as much work concurrently as possible
+ gcphase = _GCscan
systemstack(starttheworld)
gctimer.cycle.scan = nanotime()
// Do a concurrent heap scan before we stop the world.