Skip to content

Commit 84eacea

Browse files
mknyszekgopherbot
authored andcommitted
runtime: add sysNoHugePage
Change-Id: Icccafb896de838256a2ec7c3f385e6cbb2b415fa Reviewed-on: https://go-review.googlesource.com/c/go/+/447360 Auto-Submit: Michael Knyszek <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Run-TryBot: Michael Knyszek <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 76ac54b commit 84eacea

File tree

7 files changed

+26
-0
lines changed

7 files changed

+26
-0
lines changed

src/runtime/mem.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ func sysHugePage(v unsafe.Pointer, n uintptr) {
8484
sysHugePageOS(v, n)
8585
}
8686

87+
// sysNoHugePage does not transition memory regions, but instead provides a
88+
// hint to the OS that it would be less efficient to back this memory region
89+
// with pages of a larger size transparently.
90+
func sysNoHugePage(v unsafe.Pointer, n uintptr) {
91+
sysNoHugePageOS(v, n)
92+
}
93+
8794
// sysFree transitions a memory region from any state to None. Therefore, it
8895
// returns memory unconditionally. It is used if an out-of-memory error has been
8996
// detected midway through an allocation or to carve out an aligned section of

src/runtime/mem_aix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
3838
func sysHugePageOS(v unsafe.Pointer, n uintptr) {
3939
}
4040

41+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
42+
}
43+
4144
// Don't split the stack as this function may be invoked without a valid G,
4245
// which prevents us from allocating more stack.
4346
//

src/runtime/mem_bsd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
3636
func sysHugePageOS(v unsafe.Pointer, n uintptr) {
3737
}
3838

39+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
40+
}
41+
3942
// Don't split the stack as this function may be invoked without a valid G,
4043
// which prevents us from allocating more stack.
4144
//

src/runtime/mem_darwin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
3636
func sysHugePageOS(v unsafe.Pointer, n uintptr) {
3737
}
3838

39+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
40+
}
41+
3942
// Don't split the stack as this function may be invoked without a valid G,
4043
// which prevents us from allocating more stack.
4144
//

src/runtime/mem_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ func sysHugePageOS(v unsafe.Pointer, n uintptr) {
161161
}
162162
}
163163

164+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
165+
madvise(v, n, _MADV_NOHUGEPAGE)
166+
}
167+
164168
// Don't split the stack as this function may be invoked without a valid G,
165169
// which prevents us from allocating more stack.
166170
//

src/runtime/mem_sbrk.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
160160
func sysHugePageOS(v unsafe.Pointer, n uintptr) {
161161
}
162162

163+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
164+
}
165+
163166
func sysMapOS(v unsafe.Pointer, n uintptr) {
164167
}
165168

src/runtime/mem_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
9494
func sysHugePageOS(v unsafe.Pointer, n uintptr) {
9595
}
9696

97+
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
98+
}
99+
97100
// Don't split the stack as this function may be invoked without a valid G,
98101
// which prevents us from allocating more stack.
99102
//

0 commit comments

Comments
 (0)