]> Cypherpunks repositories - gostls13.git/commit
runtime: fix two garbage collector bugs
authorRuss Cox <rsc@golang.org>
Mon, 5 Jan 2015 20:02:09 +0000 (15:02 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 6 Jan 2015 15:10:13 +0000 (15:10 +0000)
commit02f89331c2ec09923806611bc1a8fbb2ffcbcca5
treee0fedd0eafa998ad158c15f6096f18dfdc4c4d93
parentff979626fc14eb0debcce44494ca114879de618d
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>
src/runtime/malloc.go
src/runtime/mgc.go