aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-08-25 18:02:30 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-08-25 18:02:30 +0400
commit846db08936ee89b95d002b6f38e26d84eece6eec (patch)
treee9d1f39b0060cc4b48f20d4d9e4cc128fee5ffe0 /src/pkg/runtime
parent99080c4b6f29aa6ea988747c43475469e761c8a5 (diff)
downloadgo-846db08936ee89b95d002b6f38e26d84eece6eec.tar.xz
runtime: fix plan9 HeapSys accounting
LGTM=0intro R=0intro CC=golang-codereviews https://golang.org/cl/131190043
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/mem_plan9.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/pkg/runtime/mem_plan9.c b/src/pkg/runtime/mem_plan9.c
index bbf04c7eda..ea35a1709c 100644
--- a/src/pkg/runtime/mem_plan9.c
+++ b/src/pkg/runtime/mem_plan9.c
@@ -17,8 +17,8 @@ enum
Round = PAGESIZE-1
};
-void*
-runtime·SysAlloc(uintptr nbytes, uint64 *stat)
+static void*
+brk(uintptr nbytes)
{
uintptr bl;
@@ -31,8 +31,19 @@ runtime·SysAlloc(uintptr nbytes, uint64 *stat)
}
bloc = (byte*)bl + nbytes;
runtime·unlock(&memlock);
- runtime·xadd64(stat, nbytes);
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
@@ -64,7 +75,10 @@ runtime·SysUsed(void *v, uintptr nbytes)
void
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
@@ -78,5 +92,5 @@ runtime·SysReserve(void *v, uintptr nbytes, bool *reserved)
{
USED(v);
*reserved = true;
- return runtime·SysAlloc(nbytes, &mstats.heap_sys);
+ return brk(nbytes);
}