diff options
| author | Russ Cox <rsc@golang.org> | 2014-03-06 18:34:29 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-03-06 18:34:29 -0500 |
| commit | da1bea0ef0355482e78b8dc0f3cf2f992a8464d7 (patch) | |
| tree | 58b71ad767a3bc2cbee8229d0d88f28f097de47a /src/pkg/runtime/malloc.h | |
| parent | 1d2b7171d500bbd549d6915b3d65340c117807fc (diff) | |
| download | go-da1bea0ef0355482e78b8dc0f3cf2f992a8464d7.tar.xz | |
runtime: fix malloc page alignment + efence
Two memory allocator bug fixes.
- efence is not maintaining the proper heap metadata
to make eventual memory reuse safe, so use SysFault.
- now that our heap PageSize is 8k but most hardware
uses 4k pages, SysAlloc and SysReserve results must be
explicitly aligned. Do that in a few more call sites and
document this fact in malloc.h.
Fixes #7448.
LGTM=iant
R=golang-codereviews, josharian, iant
CC=dvyukov, golang-codereviews
https://golang.org/cl/71750048
Diffstat (limited to 'src/pkg/runtime/malloc.h')
| -rw-r--r-- | src/pkg/runtime/malloc.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index 84e438d455..7583b4b4e3 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -158,6 +158,9 @@ struct MLink // SysAlloc obtains a large chunk of zeroed memory from the // operating system, typically on the order of a hundred kilobytes // or a megabyte. +// NOTE: SysAlloc returns OS-aligned memory, but the heap allocator +// may use larger alignment, so the caller must be careful to realign the +// memory obtained by SysAlloc. // // SysUnused notifies the operating system that the contents // of the memory region are no longer needed and can be reused @@ -173,6 +176,9 @@ struct MLink // If the pointer passed to it is non-nil, the caller wants the // reservation there, but SysReserve can still choose another // location if that one is unavailable. +// NOTE: SysReserve returns OS-aligned memory, but the heap allocator +// may use larger alignment, so the caller must be careful to realign the +// memory obtained by SysAlloc. // // SysMap maps previously reserved address space for use. // |
