]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove sys.HugePageSize
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 24 Apr 2019 17:01:11 +0000 (17:01 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 3 May 2019 18:42:04 +0000 (18:42 +0000)
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: Austin Clements <austin@google.com>
14 files changed:
src/runtime/internal/sys/arch_386.go
src/runtime/internal/sys/arch_amd64.go
src/runtime/internal/sys/arch_amd64p32.go
src/runtime/internal/sys/arch_arm.go
src/runtime/internal/sys/arch_arm64.go
src/runtime/internal/sys/arch_mips.go
src/runtime/internal/sys/arch_mips64.go
src/runtime/internal/sys/arch_mips64le.go
src/runtime/internal/sys/arch_mipsle.go
src/runtime/internal/sys/arch_ppc64.go
src/runtime/internal/sys/arch_ppc64le.go
src/runtime/internal/sys/arch_s390x.go
src/runtime/internal/sys/arch_wasm.go
src/runtime/mem_linux.go

index 537570133709d788f26a394ffd7fff1f385d24d3..3426fd170219e445f4a141617a5d5a28d9f30c77 100644 (file)
@@ -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
 )
 
index 86fed4d53102f1697614179942ddc0ab2adbc41d..3d6776e71eea54654553c99b4794e3177c804abb 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 4096
        PCQuantum           = 1
        Int64Align          = 8
-       HugePageSize        = 1 << 21
        MinFrameSize        = 0
 )
 
index 749d724809f2bf32b2d3a4e58bd239973ec43d17..d51c8a5354cd07f1f5ca1feb6f39204204146f20 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536*GoosNacl + 4096*(1-GoosNacl)
        PCQuantum           = 1
        Int64Align          = 8
-       HugePageSize        = 1 << 21
        MinFrameSize        = 0
 )
 
index 2af09e0e35491ec5df97ca7cfa2fadab9f1ea43a..97960d6f83181272442185ee4a58883cb64e3549 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 4
-       HugePageSize        = 0
        MinFrameSize        = 4
 )
 
index f13d2de129aa978c18714b66f6867b1b08139e65..911a9485e1d675062b929d1b852dcc5f628536af 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 8
 )
 
index e9bd69c928e481659d018f67dae815429029c6d3..75cdb2e07fdd2b7e9fa8e799490543c68389e9ac 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 4
-       HugePageSize        = 0
        MinFrameSize        = 4
 )
 
index 5eb7b2b7b13463ff7f0fd7a8750956be22fd1af8..494291a802c2b4385eabc84fb475fd1168016800 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 16384
        PCQuantum           = 4
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 8
 )
 
index 14c804ed85bb07df35bbae95a45e70d3e7e5993d..d36d1202f690eb15cf5696e52599b079f95b6bce 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 16384
        PCQuantum           = 4
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 8
 )
 
index 91badb17d51753404118da805cb5903d42abf214..323bf820591b1b3721212f3d4dcebc91bd4df923 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 4
-       HugePageSize        = 0
        MinFrameSize        = 4
 )
 
index 8cde4e18d0cd61424891bff89935afbd1e9b982e..da1fe3d596c8b982c36a492c9d4ab88808c88c90 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 32
 )
 
index 10c0066849a9545a02790db9b9f32b6599efe332..605979903a87d4ad18f5e86997947a9e7e3a19d2 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 4
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 32
 )
 
index 77fd4bf07d7db54e9a11248f57846bf82047dd2b..12cb8a0fcbaad64da9d561561970b47928730b6c 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 4096
        PCQuantum           = 2
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 8
 )
 
index 203fc2e472b28df88a9ad24b28d5925e8ae8bef6..eb825df62622ec9f2aa93da6f09bb1235d779bc7 100644 (file)
@@ -10,7 +10,6 @@ const (
        DefaultPhysPageSize = 65536
        PCQuantum           = 1
        Int64Align          = 8
-       HugePageSize        = 0
        MinFrameSize        = 0
 )
 
index 1e45ed6301568f5a0b3d5a7b7c6d69d121557911..bf399227a1215dde54dffcfa246d480ba48a4e15 100644 (file)
@@ -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)