runtime: add sysNoHugePage

Change-Id: Icccafb896de838256a2ec7c3f385e6cbb2b415fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/447360
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Michael Anthony Knyszek 2022-11-02 16:47:09 +00:00 committed by Gopher Robot
parent 76ac54b50e
commit 84eaceaba7
7 changed files with 26 additions and 0 deletions

View File

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

View File

@ -38,6 +38,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
func sysHugePageOS(v unsafe.Pointer, n uintptr) { func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
}
// Don't split the stack as this function may be invoked without a valid G, // Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack. // which prevents us from allocating more stack.
// //

View File

@ -36,6 +36,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
func sysHugePageOS(v unsafe.Pointer, n uintptr) { func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
}
// Don't split the stack as this function may be invoked without a valid G, // Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack. // which prevents us from allocating more stack.
// //

View File

@ -36,6 +36,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
func sysHugePageOS(v unsafe.Pointer, n uintptr) { func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
}
// Don't split the stack as this function may be invoked without a valid G, // Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack. // which prevents us from allocating more stack.
// //

View File

@ -161,6 +161,10 @@ func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
madvise(v, n, _MADV_NOHUGEPAGE)
}
// Don't split the stack as this function may be invoked without a valid G, // Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack. // which prevents us from allocating more stack.
// //

View File

@ -160,6 +160,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
func sysHugePageOS(v unsafe.Pointer, n uintptr) { func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
}
func sysMapOS(v unsafe.Pointer, n uintptr) { func sysMapOS(v unsafe.Pointer, n uintptr) {
} }

View File

@ -94,6 +94,9 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
func sysHugePageOS(v unsafe.Pointer, n uintptr) { func sysHugePageOS(v unsafe.Pointer, n uintptr) {
} }
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
}
// Don't split the stack as this function may be invoked without a valid G, // Don't split the stack as this function may be invoked without a valid G,
// which prevents us from allocating more stack. // which prevents us from allocating more stack.
// //