ASAN activate/deactive controls thread_local_quarantine_size_kb option.
llvm-svn: 291509
This commit is contained in:
parent
c3afb8aa3d
commit
ae8e9bbb2c
|
@ -77,12 +77,13 @@ static struct AsanDeactivatedFlags {
|
|||
|
||||
void Print() {
|
||||
Report(
|
||||
"quarantine_size_mb %d, max_redzone %d, poison_heap %d, "
|
||||
"malloc_context_size %d, alloc_dealloc_mismatch %d, "
|
||||
"allocator_may_return_null %d, coverage %d, coverage_dir %s, "
|
||||
"allocator_release_to_os_interval_ms %d\n",
|
||||
allocator_options.quarantine_size_mb, allocator_options.max_redzone,
|
||||
poison_heap, malloc_context_size,
|
||||
"quarantine_size_mb %d, thread_local_quarantine_size_kb %d, "
|
||||
"max_redzone %d, poison_heap %d, malloc_context_size %d, "
|
||||
"alloc_dealloc_mismatch %d, allocator_may_return_null %d, coverage %d, "
|
||||
"coverage_dir %s, allocator_release_to_os_interval_ms %d\n",
|
||||
allocator_options.quarantine_size_mb,
|
||||
allocator_options.thread_local_quarantine_size_kb,
|
||||
allocator_options.max_redzone, poison_heap, malloc_context_size,
|
||||
allocator_options.alloc_dealloc_mismatch,
|
||||
allocator_options.may_return_null, coverage, coverage_dir,
|
||||
allocator_options.release_to_os_interval_ms);
|
||||
|
@ -109,6 +110,7 @@ void AsanDeactivate() {
|
|||
|
||||
AllocatorOptions disabled = asan_deactivated_flags.allocator_options;
|
||||
disabled.quarantine_size_mb = 0;
|
||||
disabled.thread_local_quarantine_size_kb = 0;
|
||||
disabled.min_redzone = 16; // Redzone must be at least 16 bytes long.
|
||||
disabled.max_redzone = 16;
|
||||
disabled.alloc_dealloc_mismatch = false;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
ASAN_ACTIVATION_FLAG(int, redzone)
|
||||
ASAN_ACTIVATION_FLAG(int, max_redzone)
|
||||
ASAN_ACTIVATION_FLAG(int, quarantine_size_mb)
|
||||
ASAN_ACTIVATION_FLAG(int, thread_local_quarantine_size_kb)
|
||||
ASAN_ACTIVATION_FLAG(bool, alloc_dealloc_mismatch)
|
||||
ASAN_ACTIVATION_FLAG(bool, poison_heap)
|
||||
|
||||
|
|
|
@ -49,18 +49,20 @@ class Quarantine {
|
|||
}
|
||||
|
||||
void Init(uptr size, uptr cache_size) {
|
||||
atomic_store(&max_size_, size, memory_order_release);
|
||||
atomic_store(&max_size_, size, memory_order_relaxed);
|
||||
atomic_store(&min_size_, size / 10 * 9,
|
||||
memory_order_release); // 90% of max size.
|
||||
max_cache_size_ = cache_size;
|
||||
memory_order_relaxed); // 90% of max size.
|
||||
atomic_store(&max_cache_size_, cache_size, memory_order_relaxed);
|
||||
}
|
||||
|
||||
uptr GetSize() const { return atomic_load(&max_size_, memory_order_acquire); }
|
||||
uptr GetCacheSize() const { return max_cache_size_; }
|
||||
uptr GetSize() const { return atomic_load(&max_size_, memory_order_relaxed); }
|
||||
uptr GetCacheSize() const {
|
||||
return atomic_load(&max_cache_size_, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void Put(Cache *c, Callback cb, Node *ptr, uptr size) {
|
||||
c->Enqueue(cb, ptr, size);
|
||||
if (c->Size() > max_cache_size_)
|
||||
if (c->Size() > GetCacheSize())
|
||||
Drain(c, cb);
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ class Quarantine {
|
|||
char pad0_[kCacheLineSize];
|
||||
atomic_uintptr_t max_size_;
|
||||
atomic_uintptr_t min_size_;
|
||||
uptr max_cache_size_;
|
||||
atomic_uintptr_t max_cache_size_;
|
||||
char pad1_[kCacheLineSize];
|
||||
SpinMutex cache_mutex_;
|
||||
SpinMutex recycle_mutex_;
|
||||
|
@ -92,7 +94,7 @@ class Quarantine {
|
|||
|
||||
void NOINLINE Recycle(Callback cb) {
|
||||
Cache tmp;
|
||||
uptr min_size = atomic_load(&min_size_, memory_order_acquire);
|
||||
uptr min_size = atomic_load(&min_size_, memory_order_relaxed);
|
||||
{
|
||||
SpinMutexLock l(&cache_mutex_);
|
||||
while (cache_.Size() > min_size) {
|
||||
|
|
Loading…
Reference in New Issue