aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mem_linux.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-07-18 12:24:02 -0400
committerAustin Clements <austin@google.com>2016-09-06 21:05:53 +0000
commit6dda7b2f5fb675a2747fea5ae020248245b8903f (patch)
tree77629c710cf45e34a80ed829b3e18eb151b8e3a7 /src/runtime/mem_linux.go
parent276a52de55fb48c4e56a778f1f7cac9292d8fad7 (diff)
downloadgo-6dda7b2f5fb675a2747fea5ae020248245b8903f.tar.xz
runtime: don't hard-code physical page size
Now that the runtime fetches the true physical page size from the OS, make the physical page size used by heap growth a variable instead of a constant. This isn't used in any performance-critical paths, so it shouldn't be an issue. sys.PhysPageSize is also renamed to sys.DefaultPhysPageSize to make it clear that it's not necessarily the true page size. There are no uses of this constant any more, but we'll keep it around for now. Updates #12480 and #10180. Change-Id: I6c23b9df860db309c38c8287a703c53817754f03 Reviewed-on: https://go-review.googlesource.com/25022 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mem_linux.go')
-rw-r--r--src/runtime/mem_linux.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/runtime/mem_linux.go b/src/runtime/mem_linux.go
index cd0bf26328..094658de51 100644
--- a/src/runtime/mem_linux.go
+++ b/src/runtime/mem_linux.go
@@ -22,17 +22,14 @@ const (
var addrspace_vec [1]byte
func addrspace_free(v unsafe.Pointer, n uintptr) bool {
- // Step by the minimum possible physical page size. This is
- // safe even if we have the wrong physical page size; mincore
- // will just return EINVAL for unaligned addresses.
- for off := uintptr(0); off < n; off += minPhysPageSize {
+ for off := uintptr(0); off < n; off += physPageSize {
// Use a length of 1 byte, which the kernel will round
// up to one physical page regardless of the true
// physical page size.
errval := mincore(unsafe.Pointer(uintptr(v)+off), 1, &addrspace_vec[0])
if errval == -_EINVAL {
// Address is not a multiple of the physical
- // page size. That's fine.
+ // page size. Shouldn't happen, but just ignore it.
continue
}
// ENOMEM means unmapped, which is what we want.
@@ -138,7 +135,7 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
}
}
- if uintptr(v)&(sys.PhysPageSize-1) != 0 || n&(sys.PhysPageSize-1) != 0 {
+ if uintptr(v)&(physPageSize-1) != 0 || n&(physPageSize-1) != 0 {
// madvise will round this to any physical page
// *covered* by this range, so an unaligned madvise
// will release more memory than intended.