]> Cypherpunks repositories - gostls13.git/commit
runtime: make maxOffAddr reflect the actual address space upper bound
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 12 May 2020 16:08:50 +0000 (16:08 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 14 May 2020 16:20:19 +0000 (16:20 +0000)
commit796786cd0cc1ed71da65fe9f1760b390b189c5cd
treeafc30d5e46518025a2596b2ac679b5bd24107c70
parent364a05e2feab48611bb5e4f26f47a02b9b49a988
runtime: make maxOffAddr reflect the actual address space upper bound

Currently maxOffAddr is defined in terms of the whole 64-bit address
space, assuming that it's all supported, by using ^uintptr(0) as the
maximal address in the offset space. In reality, the maximal address in
the offset space is (1<<heapAddrBits)-1 because we don't have more than
that actually available to us on a given platform.

On most platforms this is fine, because arenaBaseOffset is just
connecting two segments of address space, but on AIX we use it as an
actual offset for the starting address of the available address space,
which is limited. This means using ^uintptr(0) as the maximal address in
the offset address space causes wrap-around, especially when we just
want to represent a range approximately like [addr, infinity), which
today we do by using maxOffAddr.

To fix this, we define maxOffAddr more appropriately, in terms of
(1<<heapAddrBits)-1.

This change also redefines arenaBaseOffset to not be the negation of the
virtual address corresponding to address zero in the virtual address
space, but instead directly as the virtual address corresponding to
zero. This matches the existing documentation more closely and makes the
logic around arenaBaseOffset decidedly simpler, especially when trying
to reason about its use on AIX.

Fixes #38966.

Change-Id: I1336e5036a39de846f64cc2d253e8536dee57611
Reviewed-on: https://go-review.googlesource.com/c/go/+/233497
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/export_test.go
src/runtime/malloc.go
src/runtime/mheap.go
src/runtime/mpagealloc.go
src/runtime/mranges.go