]> Cypherpunks repositories - gostls13.git/commit
runtime: fix mark 2 completion in fractional/idle workers
authorAustin Clements <austin@google.com>
Fri, 24 Jul 2015 20:38:19 +0000 (16:38 -0400)
committerAustin Clements <austin@google.com>
Mon, 27 Jul 2015 19:58:56 +0000 (19:58 +0000)
commitcf225a1748a9efe401edd3cf8879692391a31d8b
tree00a6c0e9f7393344376b0367ee4024a9934f0c19
parentb8526a83804fa3e75ee3fc2a3a55f27791f6bd8f
runtime: fix mark 2 completion in fractional/idle workers

Currently fractional and idle mark workers dispose of their gcWork
cache during mark 2 after incrementing work.nwait and after checking
whether there are any workers or any work available. This creates a
window for two races:

1) If the only remaining work is in this worker's gcWork cache, it
   will see that there are no more workers and no more work on the
   global lists (since it has not yet flushed its own cache) and
   prematurely signal mark 2 completion.

2) After this worker has incremented work.nwait but before it has
   flushed its cache, another worker may observe that there are no
   more workers and no more work and prematurely signal mark 2
   completion.

We can fix both of these by simply moving the cache flush above the
increment of nwait and the test of the completion condition.

This is probably contributing to #11694, though this alone is not
enough to fix it.

Change-Id: Idcf9656e5c460c5ea0d23c19c6c51e951f7716c3
Reviewed-on: https://go-review.googlesource.com/12646
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go