[asan] Allocator tweaks for low memory systems.

llvm-svn: 150689
This commit is contained in:
Evgeniy Stepanov 2012-02-16 13:35:11 +00:00
parent b8fc4775d1
commit 5d47e9164c
4 changed files with 30 additions and 5 deletions

View File

@ -43,10 +43,16 @@ namespace __asan {
#define REDZONE FLAG_redzone
static const size_t kMinAllocSize = REDZONE * 2;
static const size_t kMinMmapSize = 4UL << 20; // 4M
static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17;
#if ASAN_LOW_MEMORY==1
static const size_t kMinMmapSize = 4UL << 17; // 128K
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 15; // 32K
#else
static const size_t kMinMmapSize = 4UL << 20; // 4M
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; // 128K
#endif
// Size classes less than kMallocSizeClassStep are powers of two.
// All other size classes are multiples of kMallocSizeClassStep.

View File

@ -419,7 +419,15 @@ void __asan_init() {
FLAG_v = IntFlagValue(options, "verbosity=", 0);
#if ASAN_LOW_MEMORY == 1
FLAG_quarantine_size =
IntFlagValue(options, "quarantine_size=", 1UL << 24); // 16M
FLAG_redzone = IntFlagValue(options, "redzone=", 64);
#else
FLAG_quarantine_size =
IntFlagValue(options, "quarantine_size=", 1UL << 28); // 256M
FLAG_redzone = IntFlagValue(options, "redzone=", 128);
#endif
CHECK(FLAG_redzone >= 32);
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
@ -443,9 +451,6 @@ void __asan_init() {
atexit(asan_atexit);
}
FLAG_quarantine_size =
IntFlagValue(options, "quarantine_size=", 1UL << 28);
// interceptors
InitializeAsanInterceptors();

View File

@ -453,7 +453,11 @@ static void MallocStress(size_t n) {
}
TEST(AddressSanitizer, MallocStressTest) {
#if ASAN_LOW_MEMORY==1
MallocStress(20000);
#else
MallocStress(200000);
#endif
}
static void TestLargeMalloc(size_t size) {
@ -468,6 +472,7 @@ TEST(AddressSanitizer, LargeMallocTest) {
}
}
#if ASAN_LOW_MEMORY != 1
TEST(AddressSanitizer, HugeMallocTest) {
#ifdef __APPLE__
// It was empirically found out that 1215 megabytes is the maximum amount of
@ -480,12 +485,17 @@ TEST(AddressSanitizer, HugeMallocTest) {
#endif
TestLargeMalloc(n_megs << 20);
}
#endif
TEST(AddressSanitizer, ThreadedMallocStressTest) {
const int kNumThreads = 4;
pthread_t t[kNumThreads];
for (int i = 0; i < kNumThreads; i++) {
#if ASAN_LOW_MEMORY==1
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)10000);
#else
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)100000);
#endif
}
for (int i = 0; i < kNumThreads; i++) {
pthread_join(t[i], 0);

View File

@ -39,6 +39,10 @@ using std::map;
# error "please define ASAN_NEEDS_SEGV"
#endif
#ifndef ASAN_LOW_MEMORY
#define ASAN_LOW_MEMORY 0
#endif
#define ASAN_PCRE_DOTALL ""
#endif // ASAN_TEST_CONFIG_H