diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-12-21 00:18:10 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-12-21 00:18:10 +0000 |
commit | 1a21263a89bec0b159494e64adfcd988b72b6795 (patch) | |
tree | fff4854034866b9dba6b86384c60b2f47228ca80 | |
parent | be1557ac32ff1a79cf1a8bdbeb9b963783c11299 (diff) | |
download | bcm5719-llvm-1a21263a89bec0b159494e64adfcd988b72b6795.tar.gz bcm5719-llvm-1a21263a89bec0b159494e64adfcd988b72b6795.zip |
Reduce the size of quarantine cache in ASAN_LOW_MEMORY configuration.
Summary:
Experiments show that on Android the current values result in too much
of the memory consumption for all quarantined chunks.
Reviewers: kcc, eugenis
Subscribers: mgorny, danalbert, srhines, llvm-commits, kubabrecka
Patch by Aleksey Shlyapnikov.
Differential Revision: https://reviews.llvm.org/D27873
llvm-svn: 290218
-rw-r--r-- | compiler-rt/lib/asan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 7 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_flags.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_internal.h | 2 |
4 files changed, 8 insertions, 5 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index e89d8bdabc1..1258ef6165b 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -41,8 +41,6 @@ append_rtti_flag(OFF ASAN_CFLAGS) set(ASAN_DYNAMIC_LINK_FLAGS) if(ANDROID) - list(APPEND ASAN_COMMON_DEFINITIONS - ASAN_LOW_MEMORY=1) # On Android, -z global does not do what it is documented to do. # On Android, -z global moves the library ahead in the lookup order, # placing it right after the LD_PRELOADs. This is used to compensate for the fact diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index baba5374d65..1055a8dca5f 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -227,7 +227,12 @@ struct Allocator { static const uptr kMaxAllowedMallocSize = FIRST_32_SECOND_64(3UL << 30, 1ULL << 40); static const uptr kMaxThreadLocalQuarantine = - FIRST_32_SECOND_64(1 << 18, 1 << 20); + // It is not advised to go lower than 64Kb, otherwise quarantine batches + // pushed from thread local quarantine to global one will create too much + // overhead. One quarantine batch size is 8Kb and it holds up to 1021 + // chunk, which amounts to 1/8 memory overhead per batch when thread local + // quarantine is set to 64Kb. + (ASAN_LOW_MEMORY) ? 1 << 16 : FIRST_32_SECOND_64(1 << 18, 1 << 20); AsanAllocator allocator; AsanQuarantine quarantine; diff --git a/compiler-rt/lib/asan/asan_flags.cc b/compiler-rt/lib/asan/asan_flags.cc index 345a35ce3bb..369ef0a708f 100644 --- a/compiler-rt/lib/asan/asan_flags.cc +++ b/compiler-rt/lib/asan/asan_flags.cc @@ -156,7 +156,7 @@ void InitializeFlags() { f->quarantine_size_mb = f->quarantine_size >> 20; if (f->quarantine_size_mb < 0) { const int kDefaultQuarantineSizeMb = - (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8; + (ASAN_LOW_MEMORY) ? 1UL << 4 : 1UL << 8; f->quarantine_size_mb = kDefaultQuarantineSizeMb; } if (!f->replace_str && common_flags()->intercept_strlen) { diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index 84d7f0861a6..a3fe062f73f 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -36,7 +36,7 @@ // If set, values like allocator chunk size, as well as defaults for some flags // will be changed towards less memory overhead. #ifndef ASAN_LOW_MEMORY -# if SANITIZER_IOS || (SANITIZER_WORDSIZE == 32) +# if SANITIZER_IOS || SANITIZER_ANDROID # define ASAN_LOW_MEMORY 1 # else # define ASAN_LOW_MEMORY 0 |