[llvm-commits] [compiler-rt] r150689 - in /compiler-rt/trunk/lib/asan: asan_allocator.cc asan_rtl.cc tests/asan_test.cc tests/asan_test_config.h
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Feb 16 05:35:11 PST 2012
Author: eugenis
Date: Thu Feb 16 07:35:11 2012
New Revision: 150689
URL: http://llvm.org/viewvc/llvm-project?rev=150689&view=rev
Log:
[asan] Allocator tweaks for low memory systems.
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/tests/asan_test.cc
compiler-rt/trunk/lib/asan/tests/asan_test_config.h
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=150689&r1=150688&r2=150689&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Thu Feb 16 07:35:11 2012
@@ -43,10 +43,16 @@
#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.
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=150689&r1=150688&r2=150689&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Feb 16 07:35:11 2012
@@ -419,7 +419,15 @@
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 @@
atexit(asan_atexit);
}
- FLAG_quarantine_size =
- IntFlagValue(options, "quarantine_size=", 1UL << 28);
-
// interceptors
InitializeAsanInterceptors();
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=150689&r1=150688&r2=150689&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Thu Feb 16 07:35:11 2012
@@ -453,7 +453,11 @@
}
TEST(AddressSanitizer, MallocStressTest) {
+#if ASAN_LOW_MEMORY==1
+ MallocStress(20000);
+#else
MallocStress(200000);
+#endif
}
static void TestLargeMalloc(size_t size) {
@@ -468,6 +472,7 @@
}
}
+#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 @@
#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);
Modified: compiler-rt/trunk/lib/asan/tests/asan_test_config.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test_config.h?rev=150689&r1=150688&r2=150689&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test_config.h (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test_config.h Thu Feb 16 07:35:11 2012
@@ -39,6 +39,10 @@
# 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
More information about the llvm-commits
mailing list