[PATCH] D32649: [scudo] Add Android support

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 10:25:11 PDT 2017


cryptoad created this revision.
Herald added subscribers: mgorny, srhines.

This change adds Android support to the allocator (but doesn't yet enable it in
the cmake config), and should be the last fragment of the rewritten change
https://reviews.llvm.org/D31947.

Android has more memory constraints than other platforms, so the idea of a
unique context per thread would not have worked. The alternative chosen is to
allocate a set of contexts based on the number of cores on the machine, and
share those contexts within the threads. Contexts can be dynamically reassigned
to threads to prevent contention, based on a scheme suggested by @dvyuokv in
the initial review.

Additionally, given that Android doesn't support ELF TLS (only emutls for now),
we use the TSan TLS slot to make things faster: Scudo is mutually exclusive
with other sanitizers so this shouldn't cause any problem.

An additional change made here, is replacing `thread_local` by `THREADLOCAL`
and using the initial-exec thread model in the non-Android version to prevent
extraneous weak definition and checks on the relevant variables.


https://reviews.llvm.org/D32649

Files:
  lib/scudo/CMakeLists.txt
  lib/scudo/scudo_allocator.cpp
  lib/scudo/scudo_allocator.h
  lib/scudo/scudo_tls.h
  lib/scudo/scudo_tls_android.cpp
  lib/scudo/scudo_tls_android.h
  lib/scudo/scudo_tls_linux.cpp
  lib/scudo/scudo_tls_linux.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32649.97121.patch
Type: text/x-patch
Size: 12830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170428/085e56ba/attachment.bin>


More information about the llvm-commits mailing list