runtime: force workers out before checking mark roots
runtime: force workers out before checking mark roots

Currently we check that all roots are marked as soon as gcMarkDone
decides to transition from mark 1 to mark 2. However, issue #16083
indicates that there may be a race where we try to complete mark 1
while a worker is still scanning a stack, causing the root mark check
to fail.

We don't yet understand this race, but as a simple mitigation, move
the root check to after gcMarkDone performs a ragged barrier, which
will force any remaining workers to finish their current job.

Updates #16083. This may "fix" it, but it would be better to
understand and fix the underlying race.

Change-Id: I1af9ce67bd87ade7bc2a067295d79c28cd11abd2
Reviewed-on: https://go-review.googlesource.com/35353
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>
Reviewed-by: Rick Hudson <838bd060584c511f21c75c69ea04b7b120d86af0@golang.org>

akutz/go,codestation/go,josharian/go,vsekhar/elastic-go,ImJasonH/go,nawawi/go,nawawi/go,CAFxX/go,akutz/go,polyverse-security/go,golang/go,Cofyc/go,golang/go,polyverse-security/go,Cofyc/go,ImJasonH/go,derekmarcotte/go,vsekhar/elastic-go,derekmarcotte/go,ImJasonH/go,CAFxX/go,golang/go,akutz/go,akutz/go,golang/go,CAFxX/go,golang/go,cloudflare/go,derekmarcotte/go,CAFxX/go,ImJasonH/go,codestation/go,Cofyc/go,codestation/go,nawawi/go,Cofyc/go,josharian/go,cloudflare/go,nawawi/go,josharian/go,derekmarcotte/go,codestation/go,polyverse-security/go,Cofyc/go,golang/go,vsekhar/elastic-go,cloudflare/go,linux-on-ibm-z/go,akutz/go,josharian/go,nawawi/go,linux-on-ibm-z/go,josharian/go,golang/go,derekmarcotte/go,josharian/go,Cofyc/go,ImJasonH/go,nawawi/go,cloudflare/go,cloudflare/go,codestation/go,polyverse-security/go,vsekhar/elastic-go,polyverse-security/go,vsekhar/elastic-go,codestation/go,linux-on-ibm-z/go,linux-on-ibm-z/go,CAFxX/go,vsekhar/elastic-go,linux-on-ibm-z/go,ImJasonH/go,vsekhar/elastic-go,CAFxX/go,golang/go,cloudflare/go,josharian/go,polyverse-security/go,CAFxX/go,ImJasonH/go,codestation/go,akutz/go,derekmarcotte/go,ImJasonH/go,polyverse-security/go,cloudflare/go,derekmarcotte/go,CAFxX/go,vsekhar/elastic-go,nawawi/go,Cofyc/go,linux-on-ibm-z/go,akutz/go,linux-on-ibm-z/go,derekmarcotte/go,christopher-henderson/Go,akutz/go,linux-on-ibm-z/go,cloudflare/go,josharian/go,polyverse-security/go,nawawi/go,codestation/go,Cofyc/go