Commit ab9d5f38 authored by Austin Clements's avatar Austin Clements

runtime: make gcFlushBgCredit go:nowritebarrierrec

Write barriers in gcFlushBgCredit lead to very subtle bugs because it
executes after the getfull barrier. I tracked some bugs of this form
down before go:nowritebarrierrec was implemented. Ensure that they
don't reappear by making gcFlushBgCredit go:nowritebarrierrec.

Change-Id: Ia5ca2dc59e6268bce8d8b4c87055bd0f6e19bed2
Reviewed-on: https://go-review.googlesource.com/17052Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent e126f30a
...@@ -504,6 +504,12 @@ func gcWakeAllAssists() { ...@@ -504,6 +504,12 @@ func gcWakeAllAssists() {
// credit. This first satisfies blocked assists on the // credit. This first satisfies blocked assists on the
// work.assistQueue and then flushes any remaining credit to // work.assistQueue and then flushes any remaining credit to
// gcController.bgScanCredit. // gcController.bgScanCredit.
//
// Write barriers are disallowed because this is used by gcDrain after
// it has ensured that all work is drained and this must preserve that
// condition.
//
//go:nowritebarrierrec
func gcFlushBgCredit(scanWork int64) { func gcFlushBgCredit(scanWork int64) {
if work.assistQueue.head == 0 { if work.assistQueue.head == 0 {
// Fast path; there are no blocked assists. There's a // Fast path; there are no blocked assists. There's a
...@@ -846,6 +852,10 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { ...@@ -846,6 +852,10 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) {
} }
} }
// In blocking mode, write barriers are not allowed after this
// point because we must preserve the condition that the work
// buffers are empty.
// Flush remaining scan work credit. // Flush remaining scan work credit.
if gcw.scanWork > 0 { if gcw.scanWork > 0 {
atomic.Xaddint64(&gcController.scanWork, gcw.scanWork) atomic.Xaddint64(&gcController.scanWork, gcw.scanWork)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment