Commit 7fcba815 authored by Michael Anthony Knyszek's avatar Michael Anthony Knyszek Committed by Michael Knyszek

runtime: remove sys.HugePageSize

sys.HugePageSize was superceded in the last commit by physHugePageSize
which is determined dynamically by querying the operating system.

For #30333.

Change-Id: I827bfca8bdb347e989cead31564a8fffe56c66ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/173757
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 1033065e
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = GoosNacl*65536 + (1-GoosNacl)*4096 // 4k normally; 64k on NaCl
PCQuantum = 1
Int64Align = 4
HugePageSize = 1 << 21
MinFrameSize = 0
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 4096
PCQuantum = 1
Int64Align = 8
HugePageSize = 1 << 21
MinFrameSize = 0
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536*GoosNacl + 4096*(1-GoosNacl)
PCQuantum = 1
Int64Align = 8
HugePageSize = 1 << 21
MinFrameSize = 0
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 4
HugePageSize = 0
MinFrameSize = 4
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 8
HugePageSize = 0
MinFrameSize = 8
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 4
HugePageSize = 0
MinFrameSize = 4
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 16384
PCQuantum = 4
Int64Align = 8
HugePageSize = 0
MinFrameSize = 8
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 16384
PCQuantum = 4
Int64Align = 8
HugePageSize = 0
MinFrameSize = 8
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 4
HugePageSize = 0
MinFrameSize = 4
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 8
HugePageSize = 0
MinFrameSize = 32
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 4
Int64Align = 8
HugePageSize = 0
MinFrameSize = 32
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 4096
PCQuantum = 2
Int64Align = 8
HugePageSize = 0
MinFrameSize = 8
)
......
......@@ -10,7 +10,6 @@ const (
DefaultPhysPageSize = 65536
PCQuantum = 1
Int64Align = 8
HugePageSize = 0
MinFrameSize = 0
)
......
......@@ -6,7 +6,6 @@ package runtime
import (
"runtime/internal/atomic"
"runtime/internal/sys"
"unsafe"
)
......@@ -63,37 +62,35 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
// gets most of the benefit of huge pages while keeping the
// number of VMAs under control. With hugePageSize = 2MB, even
// a pessimal heap can reach 128GB before running out of VMAs.
if sys.HugePageSize != 0 {
var s uintptr = sys.HugePageSize // division by constant 0 is a compile-time error :(
if physHugePageSize != 0 {
// If it's a large allocation, we want to leave huge
// pages enabled. Hence, we only adjust the huge page
// flag on the huge pages containing v and v+n-1, and
// only if those aren't aligned.
var head, tail uintptr
if uintptr(v)%s != 0 {
if uintptr(v)%physHugePageSize != 0 {
// Compute huge page containing v.
head = uintptr(v) &^ (s - 1)
head = uintptr(v) &^ (physHugePageSize - 1)
}
if (uintptr(v)+n)%s != 0 {
if (uintptr(v)+n)%physHugePageSize != 0 {
// Compute huge page containing v+n-1.
tail = (uintptr(v) + n - 1) &^ (s - 1)
tail = (uintptr(v) + n - 1) &^ (physHugePageSize - 1)
}
// Note that madvise will return EINVAL if the flag is
// already set, which is quite likely. We ignore
// errors.
if head != 0 && head+sys.HugePageSize == tail {
if head != 0 && head+physHugePageSize == tail {
// head and tail are different but adjacent,
// so do this in one call.
madvise(unsafe.Pointer(head), 2*sys.HugePageSize, _MADV_NOHUGEPAGE)
madvise(unsafe.Pointer(head), 2*physHugePageSize, _MADV_NOHUGEPAGE)
} else {
// Advise the huge pages containing v and v+n-1.
if head != 0 {
madvise(unsafe.Pointer(head), sys.HugePageSize, _MADV_NOHUGEPAGE)
madvise(unsafe.Pointer(head), physHugePageSize, _MADV_NOHUGEPAGE)
}
if tail != 0 && tail != head {
madvise(unsafe.Pointer(tail), sys.HugePageSize, _MADV_NOHUGEPAGE)
madvise(unsafe.Pointer(tail), physHugePageSize, _MADV_NOHUGEPAGE)
}
}
}
......@@ -120,7 +117,7 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
}
func sysUsed(v unsafe.Pointer, n uintptr) {
if sys.HugePageSize != 0 {
if physHugePageSize != 0 {
// Partially undo the NOHUGEPAGE marks from sysUnused
// for whole huge pages between v and v+n. This may
// leave huge pages off at the end points v and v+n
......@@ -129,12 +126,11 @@ func sysUsed(v unsafe.Pointer, n uintptr) {
// the end points as well, but it's probably not worth
// the cost because when neighboring allocations are
// freed sysUnused will just set NOHUGEPAGE again.
var s uintptr = sys.HugePageSize
// Round v up to a huge page boundary.
beg := (uintptr(v) + (s - 1)) &^ (s - 1)
beg := (uintptr(v) + (physHugePageSize - 1)) &^ (physHugePageSize - 1)
// Round v+n down to a huge page boundary.
end := (uintptr(v) + n) &^ (s - 1)
end := (uintptr(v) + n) &^ (physHugePageSize - 1)
if beg < end {
madvise(unsafe.Pointer(beg), end-beg, _MADV_HUGEPAGE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment