Skip to content

Commit 7fcba81

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 1033065 commit 7fcba81

14 files changed

+12
-29
lines changed

src/runtime/internal/sys/arch_386.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = GoosNacl*65536 + (1-GoosNacl)*4096 // 4k normally; 64k on NaCl
1111
PCQuantum = 1
1212
Int64Align = 4
13-
HugePageSize = 1 << 21
1413
MinFrameSize = 0
1514
)
1615

src/runtime/internal/sys/arch_amd64.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 4096
1111
PCQuantum = 1
1212
Int64Align = 8
13-
HugePageSize = 1 << 21
1413
MinFrameSize = 0
1514
)
1615

src/runtime/internal/sys/arch_amd64p32.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536*GoosNacl + 4096*(1-GoosNacl)
1111
PCQuantum = 1
1212
Int64Align = 8
13-
HugePageSize = 1 << 21
1413
MinFrameSize = 0
1514
)
1615

src/runtime/internal/sys/arch_arm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 4
13-
HugePageSize = 0
1413
MinFrameSize = 4
1514
)
1615

src/runtime/internal/sys/arch_arm64.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 8
1514
)
1615

src/runtime/internal/sys/arch_mips.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 4
13-
HugePageSize = 0
1413
MinFrameSize = 4
1514
)
1615

src/runtime/internal/sys/arch_mips64.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 16384
1111
PCQuantum = 4
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 8
1514
)
1615

src/runtime/internal/sys/arch_mips64le.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 16384
1111
PCQuantum = 4
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 8
1514
)
1615

src/runtime/internal/sys/arch_mipsle.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 4
13-
HugePageSize = 0
1413
MinFrameSize = 4
1514
)
1615

src/runtime/internal/sys/arch_ppc64.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 32
1514
)
1615

src/runtime/internal/sys/arch_ppc64le.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 4
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 32
1514
)
1615

src/runtime/internal/sys/arch_s390x.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 4096
1111
PCQuantum = 2
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 8
1514
)
1615

src/runtime/internal/sys/arch_wasm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const (
1010
DefaultPhysPageSize = 65536
1111
PCQuantum = 1
1212
Int64Align = 8
13-
HugePageSize = 0
1413
MinFrameSize = 0
1514
)
1615

src/runtime/mem_linux.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package runtime
66

77
import (
88
"runtime/internal/atomic"
9-
"runtime/internal/sys"
109
"unsafe"
1110
)
1211

@@ -63,37 +62,35 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
6362
// gets most of the benefit of huge pages while keeping the
6463
// number of VMAs under control. With hugePageSize = 2MB, even
6564
// a pessimal heap can reach 128GB before running out of VMAs.
66-
if sys.HugePageSize != 0 {
67-
var s uintptr = sys.HugePageSize // division by constant 0 is a compile-time error :(
68-
65+
if physHugePageSize != 0 {
6966
// If it's a large allocation, we want to leave huge
7067
// pages enabled. Hence, we only adjust the huge page
7168
// flag on the huge pages containing v and v+n-1, and
7269
// only if those aren't aligned.
7370
var head, tail uintptr
74-
if uintptr(v)%s != 0 {
71+
if uintptr(v)%physHugePageSize != 0 {
7572
// Compute huge page containing v.
76-
head = uintptr(v) &^ (s - 1)
73+
head = uintptr(v) &^ (physHugePageSize - 1)
7774
}
78-
if (uintptr(v)+n)%s != 0 {
75+
if (uintptr(v)+n)%physHugePageSize != 0 {
7976
// Compute huge page containing v+n-1.
80-
tail = (uintptr(v) + n - 1) &^ (s - 1)
77+
tail = (uintptr(v) + n - 1) &^ (physHugePageSize - 1)
8178
}
8279

8380
// Note that madvise will return EINVAL if the flag is
8481
// already set, which is quite likely. We ignore
8582
// errors.
86-
if head != 0 && head+sys.HugePageSize == tail {
83+
if head != 0 && head+physHugePageSize == tail {
8784
// head and tail are different but adjacent,
8885
// so do this in one call.
89-
madvise(unsafe.Pointer(head), 2*sys.HugePageSize, _MADV_NOHUGEPAGE)
86+
madvise(unsafe.Pointer(head), 2*physHugePageSize, _MADV_NOHUGEPAGE)
9087
} else {
9188
// Advise the huge pages containing v and v+n-1.
9289
if head != 0 {
93-
madvise(unsafe.Pointer(head), sys.HugePageSize, _MADV_NOHUGEPAGE)
90+
madvise(unsafe.Pointer(head), physHugePageSize, _MADV_NOHUGEPAGE)
9491
}
9592
if tail != 0 && tail != head {
96-
madvise(unsafe.Pointer(tail), sys.HugePageSize, _MADV_NOHUGEPAGE)
93+
madvise(unsafe.Pointer(tail), physHugePageSize, _MADV_NOHUGEPAGE)
9794
}
9895
}
9996
}
@@ -120,7 +117,7 @@ func sysUnused(v unsafe.Pointer, n uintptr) {
120117
}
121118

122119
func sysUsed(v unsafe.Pointer, n uintptr) {
123-
if sys.HugePageSize != 0 {
120+
if physHugePageSize != 0 {
124121
// Partially undo the NOHUGEPAGE marks from sysUnused
125122
// for whole huge pages between v and v+n. This may
126123
// leave huge pages off at the end points v and v+n
@@ -129,12 +126,11 @@ func sysUsed(v unsafe.Pointer, n uintptr) {
129126
// the end points as well, but it's probably not worth
130127
// the cost because when neighboring allocations are
131128
// freed sysUnused will just set NOHUGEPAGE again.
132-
var s uintptr = sys.HugePageSize
133129

134130
// Round v up to a huge page boundary.
135-
beg := (uintptr(v) + (s - 1)) &^ (s - 1)
131+
beg := (uintptr(v) + (physHugePageSize - 1)) &^ (physHugePageSize - 1)
136132
// Round v+n down to a huge page boundary.
137-
end := (uintptr(v) + n) &^ (s - 1)
133+
end := (uintptr(v) + n) &^ (physHugePageSize - 1)
138134

139135
if beg < end {
140136
madvise(unsafe.Pointer(beg), end-beg, _MADV_HUGEPAGE)

0 commit comments

Comments
 (0)