Commit 3cd56b4d authored by Austin Clements's avatar Austin Clements

runtime: combine gcResetGState and gcResetMarkState

These functions are always called together and perform logically
related state resets, so combine them in to just gcResetMarkState.

Fixes #11427.

Change-Id: I06c17ef65f66186494887a767b3993126955b5fe
Reviewed-on: https://go-review.googlesource.com/16041Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent b0d5e5c5
...@@ -987,7 +987,6 @@ func gc(mode gcMode) { ...@@ -987,7 +987,6 @@ func gc(mode gcMode) {
// reclaimed until the next GC cycle. // reclaimed until the next GC cycle.
clearpools() clearpools()
gcResetGState()
gcResetMarkState() gcResetMarkState()
work.finalizersDone = false work.finalizersDone = false
...@@ -1150,7 +1149,6 @@ func gc(mode gcMode) { ...@@ -1150,7 +1149,6 @@ func gc(mode gcMode) {
// Run a full stop-the-world mark using checkmark bits, // Run a full stop-the-world mark using checkmark bits,
// to check that we didn't forget to mark anything during // to check that we didn't forget to mark anything during
// the concurrent mark process. // the concurrent mark process.
gcResetGState() // Rescan stacks
gcResetMarkState() gcResetMarkState()
initCheckmarks() initCheckmarks()
gcMark(startTime) gcMark(startTime)
...@@ -1166,7 +1164,6 @@ func gc(mode gcMode) { ...@@ -1166,7 +1164,6 @@ func gc(mode gcMode) {
// The g stacks have been scanned so // The g stacks have been scanned so
// they have gcscanvalid==true and gcworkdone==true. // they have gcscanvalid==true and gcworkdone==true.
// Reset these so that all stacks will be rescanned. // Reset these so that all stacks will be rescanned.
gcResetGState()
gcResetMarkState() gcResetMarkState()
finishsweep_m(true) finishsweep_m(true)
...@@ -1649,9 +1646,10 @@ func gcCopySpans() { ...@@ -1649,9 +1646,10 @@ func gcCopySpans() {
unlock(&mheap_.lock) unlock(&mheap_.lock)
} }
// gcResetGState resets the GC state of all G's. Any Gs created after // gcResetMarkState resets global state prior to marking (concurrent
// this will also be in this reset state. // or STW) and resets the stack scan state of all Gs. Any Gs created
func gcResetGState() { // after this will also be in the reset state.
func gcResetMarkState() {
// This may be called during a concurrent phase, so make sure // This may be called during a concurrent phase, so make sure
// allgs doesn't change. // allgs doesn't change.
lock(&allglock) lock(&allglock)
...@@ -1661,12 +1659,7 @@ func gcResetGState() { ...@@ -1661,12 +1659,7 @@ func gcResetGState() {
gp.gcAssistBytes = 0 gp.gcAssistBytes = 0
} }
unlock(&allglock) unlock(&allglock)
}
// gcResetMarkState resets state prior to marking (concurrent or STW).
//
// TODO(austin): Merge with gcResetGState. See issue #11427.
func gcResetMarkState() {
work.bytesMarked = 0 work.bytesMarked = 0
work.initialHeapLive = memstats.heap_live work.initialHeapLive = memstats.heap_live
} }
......
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