[PATCH] D34152: [sanitizer] MmapAlignedOrDie changes to reduce fragmentation

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 09:11:52 PDT 2017


cryptoad created this revision.
Herald added a subscriber: kubamracek.

The reasoning behind this change is explained in https://reviews.llvm.org/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 https://reviews.llvm.org/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 a 0 `padding_chunk` if
one was requested.


https://reviews.llvm.org/D34152

Files:
  lib/sanitizer_common/sanitizer_allocator_primary32.h
  lib/sanitizer_common/sanitizer_common.h
  lib/sanitizer_common/sanitizer_posix.cc
  lib/sanitizer_common/sanitizer_win.cc
  lib/sanitizer_common/tests/sanitizer_common_test.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34152.102348.patch
Type: text/x-patch
Size: 8977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/a039bd6b/attachment.bin>


More information about the llvm-commits mailing list