Skip to content

Commit a2a2901

Browse files
committed
runtime: track whether any buffer has been flushed from gcWork
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>
1 parent edc2d17 commit a2a2901

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/runtime/mgcwork.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ type gcWork struct {
8383
// Scan work performed on this gcWork. This is aggregated into
8484
// gcController by dispose and may also be flushed by callers.
8585
scanWork int64
86+
87+
// flushedWork indicates that a non-empty work buffer was
88+
// flushed to the global work list since the last gcMarkDone
89+
// termination check. Specifically, this indicates that this
90+
// gcWork may have communicated work to another gcWork.
91+
flushedWork bool
8692
}
8793

8894
// Most of the methods of gcWork are go:nowritebarrierrec because the
@@ -116,6 +122,7 @@ func (w *gcWork) put(obj uintptr) {
116122
wbuf = w.wbuf1
117123
if wbuf.nobj == len(wbuf.obj) {
118124
putfull(wbuf)
125+
w.flushedWork = true
119126
wbuf = getempty()
120127
w.wbuf1 = wbuf
121128
flushed = true
@@ -169,6 +176,7 @@ func (w *gcWork) putBatch(obj []uintptr) {
169176
for len(obj) > 0 {
170177
for wbuf.nobj == len(wbuf.obj) {
171178
putfull(wbuf)
179+
w.flushedWork = true
172180
w.wbuf1, w.wbuf2 = w.wbuf2, getempty()
173181
wbuf = w.wbuf1
174182
flushed = true
@@ -275,6 +283,7 @@ func (w *gcWork) dispose() {
275283
putempty(wbuf)
276284
} else {
277285
putfull(wbuf)
286+
w.flushedWork = true
278287
}
279288
w.wbuf1 = nil
280289

@@ -283,6 +292,7 @@ func (w *gcWork) dispose() {
283292
putempty(wbuf)
284293
} else {
285294
putfull(wbuf)
295+
w.flushedWork = true
286296
}
287297
w.wbuf2 = nil
288298
}
@@ -309,9 +319,11 @@ func (w *gcWork) balance() {
309319
}
310320
if wbuf := w.wbuf2; wbuf.nobj != 0 {
311321
putfull(wbuf)
322+
w.flushedWork = true
312323
w.wbuf2 = getempty()
313324
} else if wbuf := w.wbuf1; wbuf.nobj > 4 {
314325
w.wbuf1 = handoff(wbuf)
326+
w.flushedWork = true // handoff did putfull
315327
} else {
316328
return
317329
}

0 commit comments

Comments
 (0)