]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: track whether any buffer has been flushed from gcWork
authorAustin Clements <austin@google.com>
Fri, 3 Aug 2018 19:04:14 +0000 (15:04 -0400)
committerAustin Clements <austin@google.com>
Tue, 2 Oct 2018 20:35:19 +0000 (20:35 +0000)
Nothing currently consumes the flag, but we'll use it in the
distributed termination detection algorithm.

Updates #26903. This is preparation for eliminating mark 2.

Change-Id: I5e149a05b1c878fe1009150da21f8bd8ae2b9b6a
Reviewed-on: https://go-review.googlesource.com/c/134317
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgcwork.go

index 99771e2e57f2cccfd5bd3e030fbc5f4b62426cfd..27e73d6c4a6c39e64fa0aa9f59103b7038314724 100644 (file)
@@ -83,6 +83,12 @@ type gcWork struct {
        // Scan work performed on this gcWork. This is aggregated into
        // gcController by dispose and may also be flushed by callers.
        scanWork int64
+
+       // flushedWork indicates that a non-empty work buffer was
+       // flushed to the global work list since the last gcMarkDone
+       // termination check. Specifically, this indicates that this
+       // gcWork may have communicated work to another gcWork.
+       flushedWork bool
 }
 
 // Most of the methods of gcWork are go:nowritebarrierrec because the
@@ -116,6 +122,7 @@ func (w *gcWork) put(obj uintptr) {
                wbuf = w.wbuf1
                if wbuf.nobj == len(wbuf.obj) {
                        putfull(wbuf)
+                       w.flushedWork = true
                        wbuf = getempty()
                        w.wbuf1 = wbuf
                        flushed = true
@@ -169,6 +176,7 @@ func (w *gcWork) putBatch(obj []uintptr) {
        for len(obj) > 0 {
                for wbuf.nobj == len(wbuf.obj) {
                        putfull(wbuf)
+                       w.flushedWork = true
                        w.wbuf1, w.wbuf2 = w.wbuf2, getempty()
                        wbuf = w.wbuf1
                        flushed = true
@@ -275,6 +283,7 @@ func (w *gcWork) dispose() {
                        putempty(wbuf)
                } else {
                        putfull(wbuf)
+                       w.flushedWork = true
                }
                w.wbuf1 = nil
 
@@ -283,6 +292,7 @@ func (w *gcWork) dispose() {
                        putempty(wbuf)
                } else {
                        putfull(wbuf)
+                       w.flushedWork = true
                }
                w.wbuf2 = nil
        }
@@ -309,9 +319,11 @@ func (w *gcWork) balance() {
        }
        if wbuf := w.wbuf2; wbuf.nobj != 0 {
                putfull(wbuf)
+               w.flushedWork = true
                w.wbuf2 = getempty()
        } else if wbuf := w.wbuf1; wbuf.nobj > 4 {
                w.wbuf1 = handoff(wbuf)
+               w.flushedWork = true // handoff did putfull
        } else {
                return
        }