]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: rename gosweepdone to isSweepDone and document better
authorAustin Clements <austin@google.com>
Tue, 25 Sep 2018 21:41:11 +0000 (17:41 -0400)
committerAustin Clements <austin@google.com>
Tue, 9 Oct 2018 18:32:08 +0000 (18:32 +0000)
gosweepdone is another anachronism from the time when the sweeper was
implemented in C. Rename it to "isSweepDone" for the modern era.

Change-Id: I8472aa6f52478459c3f2edc8a4b2761e73c4c2dd
Reviewed-on: https://go-review.googlesource.com/c/138658
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/mgc.go
src/runtime/mgcsweep.go

index 9a35c7671f2b3d0037d958a9444c8bbb80f8fca2..e12df7f7d2055de35ad0ba6113f2c2a127bc3199 100644 (file)
@@ -789,7 +789,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
                trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio))
                // Don't trigger below the minimum heap size.
                minTrigger := heapminimum
-               if !gosweepdone() {
+               if !isSweepDone() {
                        // Concurrent sweep happens in the heap growth
                        // from heap_live to gc_trigger, so ensure
                        // that concurrent sweep has some heap growth
@@ -834,7 +834,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
        }
 
        // Update sweep pacing.
-       if gosweepdone() {
+       if isSweepDone() {
                mheap_.sweepPagesPerByte = 0
        } else {
                // Concurrent sweep needs to sweep all of the in-use
index 35b717ca9b807bbc37c59e69f89648e12336a5cc..627a6a023f9d8a37c78000dcec450cff9b4b0e39 100644 (file)
@@ -60,7 +60,7 @@ func bgsweep(c chan int) {
                        Gosched()
                }
                lock(&sweep.lock)
-               if !gosweepdone() {
+               if !isSweepDone() {
                        // This can happen if a GC runs between
                        // gosweepone returning ^0 above
                        // and the lock being acquired.
@@ -134,8 +134,13 @@ func sweepone() uintptr {
        return npages
 }
 
-//go:nowritebarrier
-func gosweepdone() bool {
+// isSweepDone reports whether all spans are swept or currently being swept.
+//
+// Note that this condition may transition from false to true at any
+// time as the sweeper runs. It may transition from true to false if a
+// GC runs; to prevent that the caller must be non-preemptible or must
+// somehow block GC progress.
+func isSweepDone() bool {
        return mheap_.sweepdone != 0
 }