Commit 846db089 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: fix plan9 HeapSys accounting

LGTM=0intro
R=0intro
CC=golang-codereviews
https://golang.org/cl/131190043
parent 99080c4b
...@@ -17,8 +17,8 @@ enum ...@@ -17,8 +17,8 @@ enum
Round = PAGESIZE-1 Round = PAGESIZE-1
}; };
void* static void*
runtime·SysAlloc(uintptr nbytes, uint64 *stat) brk(uintptr nbytes)
{ {
uintptr bl; uintptr bl;
...@@ -31,8 +31,19 @@ runtime·SysAlloc(uintptr nbytes, uint64 *stat) ...@@ -31,8 +31,19 @@ runtime·SysAlloc(uintptr nbytes, uint64 *stat)
} }
bloc = (byte*)bl + nbytes; bloc = (byte*)bl + nbytes;
runtime·unlock(&memlock); runtime·unlock(&memlock);
runtime·xadd64(stat, nbytes);
return (void*)bl; return (void*)bl;
}
void*
runtime·SysAlloc(uintptr nbytes, uint64 *stat)
{
void *p;
p = brk(nbytes);
if(p != nil)
runtime·xadd64(stat, nbytes);
return p;
} }
void void
...@@ -64,7 +75,10 @@ runtime·SysUsed(void *v, uintptr nbytes) ...@@ -64,7 +75,10 @@ runtime·SysUsed(void *v, uintptr nbytes)
void void
runtime·SysMap(void *v, uintptr nbytes, bool reserved, uint64 *stat) runtime·SysMap(void *v, uintptr nbytes, bool reserved, uint64 *stat)
{ {
USED(v, nbytes, reserved, stat); // SysReserve has already allocated all heap memory,
// but has not adjusted stats.
USED(v, reserved);
runtime·xadd64(stat, nbytes);
} }
void void
...@@ -78,5 +92,5 @@ runtime·SysReserve(void *v, uintptr nbytes, bool *reserved) ...@@ -78,5 +92,5 @@ runtime·SysReserve(void *v, uintptr nbytes, bool *reserved)
{ {
USED(v); USED(v);
*reserved = true; *reserved = true;
return runtime·SysAlloc(nbytes, &mstats.heap_sys); return brk(nbytes);
} }
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