[PATCH] D44261: [sanitizer] Align & pad the allocator structures to the cacheline size

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 10:27:38 PST 2018


cryptoad created this revision.
cryptoad added reviewers: alekseyshl, dvyukov.
Herald added subscribers: Sanitizers, delcypher, kubamracek.

Both `SizeClassInfo` structures for the 32-bit primary & `RegionInfo`
structures for the 64-bit primary can be used by different threads, and as such
they should be aligned & padded to the cacheline size to avoid false sharing.
The former was padded but the array was not aligned, the latter was not padded
but we lucked up as the size of the structure was 192 bytes, and aligned by
the properties of `mmap`.

I plan on adding a couple of fields to the `RegionInfo`, and some highly
threaded tests pointed out that without proper padding & alignment, performance
was getting a hit - and it is going away with proper padding.

This patch makes sure that we are properly padded & aligned for both. I used
a template to avoid padding if the size is already a multiple of the cacheline
size. There might be a better way to do this, I am open to suggestions.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D44261

Files:
  lib/sanitizer_common/sanitizer_allocator_primary32.h
  lib/sanitizer_common/sanitizer_allocator_primary64.h
  lib/sanitizer_common/sanitizer_common.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44261.137606.patch
Type: text/x-patch
Size: 3631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/076f5337/attachment.bin>


More information about the llvm-commits mailing list