Skip to content

Commit ecc3659

Browse files
committed
runtime: avoid using STW GC mechanism for checkmarks mode
Currently, checkmarks mode uses the full STW GC infrastructure to perform mark checking. We're about to remove that infrastructure and, furthermore, since checkmarks is about doing the simplest thing possible to check concurrent GC, it's valuable for it to be simpler. Hence, this CL makes checkmarks even simpler by making it non-parallel and divorcing it from the STW GC infrastructure (including the gchelper mechanism). Updates #26903. This is preparation for unifying STW GC and concurrent GC. Change-Id: Iad21158123e025e3f97d7986d577315e994bd43e Reviewed-on: https://go-review.googlesource.com/c/134776 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
1 parent 918ed88 commit ecc3659

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/runtime/mgc.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,12 +1513,16 @@ func gcMarkTermination(nextTriggerRatio float64) {
15131513
systemstack(func() {
15141514
work.heap2 = work.bytesMarked
15151515
if debug.gccheckmark > 0 {
1516-
// Run a full stop-the-world mark using checkmark bits,
1517-
// to check that we didn't forget to mark anything during
1518-
// the concurrent mark process.
1516+
// Run a full non-parallel, stop-the-world
1517+
// mark using checkmark bits, to check that we
1518+
// didn't forget to mark anything during the
1519+
// concurrent mark process.
15191520
gcResetMarkState()
15201521
initCheckmarks()
1521-
gcMark(startTime)
1522+
gcw := &getg().m.p.ptr().gcw
1523+
gcDrain(gcw, gcDrainNoBlock)
1524+
wbBufFlush1(getg().m.p.ptr())
1525+
gcw.dispose()
15221526
clearCheckmarks()
15231527
}
15241528

@@ -1905,12 +1909,12 @@ func gcMark(start_time int64) {
19051909
work.helperDrainBlock = false
19061910
} else {
19071911
// There's marking work to do. This is the case during
1908-
// STW GC and in checkmark mode. Instruct GC workers
1912+
// STW GC. Instruct GC workers
19091913
// to block in getfull until all GC workers are in getfull.
19101914
//
1911-
// TODO(austin): Move STW and checkmark marking out of
1915+
// TODO(austin): Move STW marking out of
19121916
// mark termination and eliminate this code path.
1913-
if !useCheckmark && debug.gcstoptheworld == 0 && debug.gcrescanstacks == 0 {
1917+
if debug.gcstoptheworld == 0 && debug.gcrescanstacks == 0 {
19141918
print("runtime: full=", hex(work.full), " nDataRoots=", work.nDataRoots, " nBSSRoots=", work.nBSSRoots, " nSpanRoots=", work.nSpanRoots, " nStackRoots=", work.nStackRoots, "\n")
19151919
panic("non-empty mark queue after concurrent mark")
19161920
}

0 commit comments

Comments
 (0)