Commit ccd1d07c authored by Shenghou Ma's avatar Shenghou Ma

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
parent 6120ef07
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment