runtime: doubly fix "double wakeup" panic
runtime: doubly fix "double wakeup" panic

runtime.gchelper depends on the non-atomic load of work.ndone
happening strictly before the atomic add of work.nwait. Until very
recently (commit 978af9c2db, fixing #20334), the compiler reordered
these operations. This created a race since work.ndone can change as
soon as work.nwait is equal to work.ndone. If that happened, more than
one gchelper could attempt to wake up the work.alldone note, causing a
"double wakeup" panic.

This was fixed in the compiler, but to make this code less subtle,
make the load of work.ndone atomic. This clearly forces the order of
these operations, ensuring the race doesn't happen.

Fixes #19305 (though really 978af9c2db fixed it).

Change-Id: Ieb1a84e1e5044c33ac612c8a5ab6297e7db4c57d
Reviewed-on: https://go-review.googlesource.com/43311
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Keith Randall <8c99c3a9284e493be632950b84cd789d08ed3e9d@golang.org>

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