aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mem_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/mem_linux.go')
-rw-r--r--src/runtime/mem_linux.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/runtime/mem_linux.go b/src/runtime/mem_linux.go
index 9aaa57ac9e..24e006debc 100644
--- a/src/runtime/mem_linux.go
+++ b/src/runtime/mem_linux.go
@@ -18,7 +18,7 @@ const (
// prevents us from allocating more stack.
//
//go:nosplit
-func sysAllocOS(n uintptr) unsafe.Pointer {
+func sysAllocOS(n uintptr, vmaName string) unsafe.Pointer {
p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
if err != 0 {
if err == _EACCES {
@@ -31,6 +31,7 @@ func sysAllocOS(n uintptr) unsafe.Pointer {
}
return nil
}
+ setVMAName(p, n, vmaName)
return p
}
@@ -70,7 +71,10 @@ func sysUnusedOS(v unsafe.Pointer, n uintptr) {
// Fall back on mmap if it's not supported.
// _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE will unmap all the
// pages in the old mapping, and remap the memory region.
- mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
+ p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
+ if err == 0 && p != nil {
+ setVMAName(p, n, "unused")
+ }
}
if debug.harddecommit > 0 {
@@ -78,6 +82,7 @@ func sysUnusedOS(v unsafe.Pointer, n uintptr) {
if p != v || err != 0 {
throw("runtime: cannot disable permissions in address space")
}
+ setVMAName(p, n, "unused")
}
}
@@ -90,6 +95,7 @@ func sysUsedOS(v unsafe.Pointer, n uintptr) {
if p != v || err != 0 {
throw("runtime: cannot remap pages in address space")
}
+ setVMAName(p, n, "used")
return
}
}
@@ -154,15 +160,16 @@ func sysFaultOS(v unsafe.Pointer, n uintptr) {
madvise(v, n, _MADV_DONTNEED)
}
-func sysReserveOS(v unsafe.Pointer, n uintptr) unsafe.Pointer {
+func sysReserveOS(v unsafe.Pointer, n uintptr, vmaName string) unsafe.Pointer {
p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
if err != 0 {
return nil
}
+ setVMAName(p, n, vmaName)
return p
}
-func sysMapOS(v unsafe.Pointer, n uintptr) {
+func sysMapOS(v unsafe.Pointer, n uintptr, vmaName string) {
p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
if err == _ENOMEM {
throw("runtime: out of memory")
@@ -171,6 +178,7 @@ func sysMapOS(v unsafe.Pointer, n uintptr) {
print("runtime: mmap(", v, ", ", n, ") returned ", p, ", ", err, "\n")
throw("runtime: cannot map pages in arena address space")
}
+ setVMAName(p, n, vmaName)
// Disable huge pages if the GODEBUG for it is set.
//