diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 1a9c3b3e5f9069b7c24e3bc3328d317efea554da..191935dfd571bb74631c70913e6815d249b47d5b 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -169,9 +169,10 @@ func (a *activeSweep) end(sl sweepLocker) { throw("mismatched begin/end of activeSweep") } if a.state.CompareAndSwap(state, state-1) { - if state != sweepDrainedMask { + if state-1 != sweepDrainedMask { return } + // We're the last sweeper, and there's nothing left to sweep. if debug.gcpacertrace > 0 { live := gcController.heapLive.Load() print("pacer: sweep done at heap size ", live>>20, "MB; allocated ", (live-mheap_.sweepHeapLiveBasis)>>20, "MB during sweep; swept ", mheap_.pagesSwept.Load(), " pages at ", mheap_.sweepPagesPerByte, " pages/byte\n")