diff options
author | Aliaksey Kandratsenka <alkondratenko@gmail.com> | 2017-02-20 21:12:58 -0800 |
---|---|---|
committer | Aliaksey Kandratsenka <alkondratenko@gmail.com> | 2017-05-14 19:04:55 -0700 |
commit | bad70249dd5c829b4981aecdc25953800d6745c3 (patch) | |
tree | 10604fcbd6cb4cf0ef8009070b0de27c1ad0f430 | |
parent | 5f12147c6dbfe2cfbdc7553521fe0110073135f0 (diff) | |
download | gperftools-bad70249dd5c829b4981aecdc25953800d6745c3.tar.gz |
use 48-bit addresses on 64-bit arms too
-rw-r--r-- | src/common.h | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/common.h b/src/common.h index e9cb795..367dd93 100644 --- a/src/common.h +++ b/src/common.h @@ -125,14 +125,27 @@ static const int kMaxDynamicFreeListLength = 8192; static const Length kMaxValidPages = (~static_cast<Length>(0)) >> kPageShift; -#if defined __x86_64__ -// All current and planned x86_64 processors only look at the lower 48 bits -// in virtual to physical address translation. The top 16 are thus unused. -// TODO(rus): Under what operating systems can we increase it safely to 17? -// This lets us use smaller page maps. On first allocation, a 36-bit page map -// uses only 96 KB instead of the 4.5 MB used by a 52-bit page map. +#if __aarch64__ || __x86_64__ +// All current x86_64 processors only look at the lower 48 bits in +// virtual to physical address translation. The top 16 are all same as +// bit 47. And bit 47 value 1 reserved for kernel-space addresses in +// practice. So it is actually 47 usable bits from malloc +// perspective. This lets us use faster two level page maps on this +// architecture. +// +// There is very similar story on 64-bit arms except it has full 48 +// bits for user-space. Because of that, and because in principle OSes +// can start giving some of highest-bit-set addresses to user-space, +// we don't bother to limit x86 to 47 bits. +// +// As of now there are published plans to add more bits to x86-64 +// virtual address space, but since 48 bits has been norm for long +// time and lots of software is relying on it, it will be opt-in from +// OS perspective. So we can keep doing "48 bits" at least for now. static const int kAddressBits = (sizeof(void*) < 8 ? (8 * sizeof(void*)) : 48); #else +// mipsen and ppcs have more general hardware so we have to support +// full 64-bits of addresses. static const int kAddressBits = 8 * sizeof(void*); #endif |