diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index ebfc803062..7b224fedfa 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -956,6 +956,15 @@ func gc(mode int) { // boundaries where there are up-pointers. setGCPhase(_GCscan) + gcBgMarkPrepare() // Must happen before assist enable. + + // At this point all Ps have enabled the write + // barrier, thus maintaining the no white to + // black invariant. Enable mutator assists to + // put back-pressure on fast allocating + // mutators. + atomicstore(&gcBlackenEnabled, 1) + // Concurrent scan. startTheWorldWithSema() now = nanotime() @@ -976,17 +985,13 @@ func gc(mode int) { forEachP(func(*p) {}) }) // Concurrent mark. - gcBgMarkPrepare() // Must happen before assist enable. - // At this point all Ps have enabled the mark phase - // write barrier, thus maintaining the no white to - // black invariant. Mutator assists and mark workers - // can now be enabled to safely blacken grey objects. - atomicstore(&gcBlackenEnabled, 1) if debug.gctrace > 0 { tMark = nanotime() } - // Wait for background mark completion. + // Enable background mark workers and wait for + // background mark completion. + gcController.bgMarkStartTime = nanotime() work.bgMark1.clear() work.bgMark1.wait() @@ -1230,7 +1235,6 @@ func gcBgMarkPrepare() { // Reset background mark completion points. work.bgMark1.done = 1 work.bgMark2.done = 1 - gcController.bgMarkStartTime = nanotime() } func gcBgMarkWorker(p *p) { diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index f7ef41692c..42aacb63a6 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -29,9 +29,7 @@ func gcscan_m() { // Prepare flag indicating that the scan has not been completed. local_allglen := gcResetGState() - work.nwait = 0 work.ndone = 0 - work.nproc = 1 useOneP := uint32(1) // For now do not do this in parallel. // ackgcphase is not needed since we are not scanning running goroutines. parforsetup(work.markfor, useOneP, uint32(_RootCount+local_allglen), false, markroot)