aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-04-29 21:02:18 +0000
committerMichael Knyszek <mknyszek@google.com>2019-05-06 20:59:20 +0000
commitf4a5ae5594a21ea276d473fe9f804a30adbd8d07 (patch)
tree64d2d4d5dfc4135270e877c2778c49b530cc8ae0 /src/runtime/export_test.go
parenta62b5723be15849656279c244834064b951801fc (diff)
downloadgo-f4a5ae5594a21ea276d473fe9f804a30adbd8d07.tar.xz
runtime: track the number of free unscavenged huge pages
This change tracks the number of potential free and unscavenged huge pages which will be used to inform the rate at which scavenging should occur. For #30333. Change-Id: I47663e5ffb64cac44ffa10db158486783f707479 Reviewed-on: https://go-review.googlesource.com/c/go/+/170860 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 852f37409e..3c3e110f89 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -36,6 +36,8 @@ var Atoi32 = atoi32
var Nanotime = nanotime
+var PhysHugePageSize = physHugePageSize
+
type LFNode struct {
Next uint64
Pushcnt uintptr
@@ -516,6 +518,26 @@ func MapTombstoneCheck(m map[int]int) {
}
}
+// UnscavHugePagesSlow returns the value of mheap_.freeHugePages
+// and the number of unscavenged huge pages calculated by
+// scanning the heap.
+func UnscavHugePagesSlow() (uintptr, uintptr) {
+ var base, slow uintptr
+ // Run on the system stack to avoid deadlock from stack growth
+ // trying to acquire the heap lock.
+ systemstack(func() {
+ lock(&mheap_.lock)
+ base = mheap_.free.unscavHugePages
+ for _, s := range mheap_.allspans {
+ if s.state == mSpanFree && !s.scavenged {
+ slow += s.hugePages()
+ }
+ }
+ unlock(&mheap_.lock)
+ })
+ return base, slow
+}
+
// Span is a safe wrapper around an mspan, whose memory
// is managed manually.
type Span struct {