summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_win.cc
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-06-14 15:32:17 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-06-14 15:32:17 +0000
commitfccfd4523bbad39dfaf5e1a9dbf7491abbc80a22 (patch)
treeaccaf126b266380aec4b9b8ecb56f88e813229f3 /lib/sanitizer_common/sanitizer_win.cc
parent2716b49e6801990c55b0dcbfcfbed120f6a364d8 (diff)
[sanitizer] MmapAlignedOrDie changes to reduce fragmentation
Summary: The reasoning behind this change is explained in D33454, which unfortunately broke the Windows version (due to the platform not supporting partial unmapping of a memory region). This new approach changes `MmapAlignedOrDie` to allow for the specification of a `padding_chunk`. If non-null, and the initial allocation is aligned, this padding chunk will hold the address of the extra memory (of `alignment` bytes). This allows `AllocateRegion` to get 2 regions if the memory is aligned properly, and thus help reduce fragmentation (and saves on unmapping operations). As with the initial D33454, we use a stash in the 32-bit Primary to hold those extra regions and return them on the fast-path. The Windows version of `MmapAlignedOrDie` will always return a 0 `padding_chunk` if one was requested. Reviewers: alekseyshl, dvyukov, kcc Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34152 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_win.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index afc3bb0ac..493167a19 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -132,10 +132,14 @@ void UnmapOrDie(void *addr, uptr size) {
}
// We want to map a chunk of address space aligned to 'alignment'.
-void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type) {
+void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type,
+ uptr *padding_chunk) {
CHECK(IsPowerOfTwo(size));
CHECK(IsPowerOfTwo(alignment));
+ if (padding_chunk)
+ *padding_chunk = 0;
+
// Windows will align our allocations to at least 64K.
alignment = Max(alignment, GetMmapGranularity());