summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-01-10 13:38:38 +0000
committerKostya Serebryany <kcc@google.com>2013-01-10 13:38:38 +0000
commitfdcfbda75046c25d451e3beaab5cd5c1aae2b637 (patch)
treee63b8a789c95c5c19c01ddc2b37f7cc92aa13d2a
parente1be48fe6480afabc35f431097750864ec66096e (diff)
downloadbcm5719-llvm-fdcfbda75046c25d451e3beaab5cd5c1aae2b637.tar.gz
bcm5719-llvm-fdcfbda75046c25d451e3beaab5cd5c1aae2b637.zip
[sanitizer] better statistics for the large allocator
llvm-svn: 172069
-rw-r--r--compiler-rt/lib/msan/msan_linux.cc1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.h13
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler-rt/lib/msan/msan_linux.cc b/compiler-rt/lib/msan/msan_linux.cc
index 02382055d2a..2203980c638 100644
--- a/compiler-rt/lib/msan/msan_linux.cc
+++ b/compiler-rt/lib/msan/msan_linux.cc
@@ -103,7 +103,6 @@ static void MsanAtExit(void) {
void InstallAtExitHandler() {
atexit(MsanAtExit);
}
-
}
#endif // __linux__
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
index 0322feb1a0c..5be234f238f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
@@ -747,6 +747,8 @@ class LargeMmapAllocator {
h->size = size;
h->map_beg = map_beg;
h->map_size = map_size;
+ uptr size_log = SANITIZER_WORDSIZE - __builtin_clzl(map_size) - 1;
+ CHECK_LT(size_log, ARRAY_SIZE(stats.by_size_log));
{
SpinMutexLock l(&mutex_);
uptr idx = n_chunks_++;
@@ -756,6 +758,7 @@ class LargeMmapAllocator {
stats.n_allocs++;
stats.currently_allocated += map_size;
stats.max_allocated = Max(stats.max_allocated, stats.currently_allocated);
+ stats.by_size_log[size_log]++;
}
return reinterpret_cast<void*>(res);
}
@@ -827,9 +830,15 @@ class LargeMmapAllocator {
void PrintStats() {
Printf("Stats: LargeMmapAllocator: allocated %zd times, "
- "remains %zd (%zd K) max %zd M\n",
+ "remains %zd (%zd K) max %zd M; by size logs: ",
stats.n_allocs, stats.n_allocs - stats.n_frees,
stats.currently_allocated >> 10, stats.max_allocated >> 20);
+ for (uptr i = 0; i < ARRAY_SIZE(stats.by_size_log); i++) {
+ uptr c = stats.by_size_log[i];
+ if (!c) continue;
+ Printf("%zd:%zd; ", i, c);
+ }
+ Printf("\n");
}
private:
@@ -860,7 +869,7 @@ class LargeMmapAllocator {
Header *chunks_[kMaxNumChunks];
uptr n_chunks_;
struct Stats {
- uptr n_allocs, n_frees, currently_allocated, max_allocated;
+ uptr n_allocs, n_frees, currently_allocated, max_allocated, by_size_log[64];
} stats;
SpinMutex mutex_;
};
OpenPOWER on IntegriCloud