diff options
| author | Shenghou Ma <minux.ma@gmail.com> | 2013-06-12 05:22:49 +0800 |
|---|---|---|
| committer | Shenghou Ma <minux.ma@gmail.com> | 2013-06-12 05:22:49 +0800 |
| commit | ccd1d07cc44f3ca033ab7ad9e93ebf97ff3fa94c (patch) | |
| tree | f620286fe0a6f279b7c41d03bdb5c2d80226077c | |
| parent | 6120ef079948340d6819b8f9a9d526ad4292e26e (diff) | |
| download | go-ccd1d07cc44f3ca033ab7ad9e93ebf97ff3fa94c.tar.xz | |
runtime: round spans_size up to page boundary
in case we have weird (not page aligned) memory limit.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10199043
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 4d900d63b9..a1db66e1ad 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -351,6 +351,8 @@ runtime·mallocinit(void) arena_size = MaxMem; bitmap_size = arena_size / (sizeof(void*)*8/4); spans_size = arena_size / PageSize * sizeof(runtime·mheap.spans[0]); + // round spans_size to pages + spans_size = (spans_size + ((1<<PageShift) - 1)) & ~((1<<PageShift) - 1); p = runtime·SysReserve((void*)(0x00c0ULL<<32), bitmap_size + spans_size + arena_size); } if (p == nil) { @@ -379,6 +381,8 @@ runtime·mallocinit(void) arena_size = bitmap_size * 8; spans_size = arena_size / PageSize * sizeof(runtime·mheap.spans[0]); } + // round spans_size to pages + spans_size = (spans_size + ((1<<PageShift) - 1)) & ~((1<<PageShift) - 1); // SysReserve treats the address we ask for, end, as a hint, // not as an absolute requirement. If we ask for the end |
