diff options
| author | Austin Clements <austin@google.com> | 2016-07-18 12:24:02 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2016-09-06 21:05:53 +0000 |
| commit | 6dda7b2f5fb675a2747fea5ae020248245b8903f (patch) | |
| tree | 77629c710cf45e34a80ed829b3e18eb151b8e3a7 /src/runtime/malloc.go | |
| parent | 276a52de55fb48c4e56a778f1f7cac9292d8fad7 (diff) | |
| download | go-6dda7b2f5fb675a2747fea5ae020248245b8903f.tar.xz | |
runtime: don't hard-code physical page size
Now that the runtime fetches the true physical page size from the OS,
make the physical page size used by heap growth a variable instead of
a constant. This isn't used in any performance-critical paths, so it
shouldn't be an issue.
sys.PhysPageSize is also renamed to sys.DefaultPhysPageSize to make it
clear that it's not necessarily the true page size. There are no uses
of this constant any more, but we'll keep it around for now.
Updates #12480 and #10180.
Change-Id: I6c23b9df860db309c38c8287a703c53817754f03
Reviewed-on: https://go-review.googlesource.com/25022
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 931af2ac93..514c0dfada 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -230,13 +230,13 @@ func mallocinit() { // The OS init code failed to fetch the physical page size. throw("failed to get system page size") } - if sys.PhysPageSize < physPageSize { - print("runtime: kernel page size (", physPageSize, ") is larger than runtime page size (", sys.PhysPageSize, ")\n") - throw("bad kernel page size") + if physPageSize < minPhysPageSize { + print("system page size (", physPageSize, ") is smaller than minimum page size (", minPhysPageSize, ")\n") + throw("bad system page size") } - if sys.PhysPageSize%physPageSize != 0 { - print("runtime: runtime page size (", sys.PhysPageSize, ") is not a multiple of kernel page size (", physPageSize, ")\n") - throw("bad kernel page size") + if physPageSize&(physPageSize-1) != 0 { + print("system page size (", physPageSize, ") must be a power of 2\n") + throw("bad system page size") } var p, bitmapSize, spansSize, pSize, limit uintptr |
