[asan] asan_allocator2: add mmap/munmap stats

llvm-svn: 170548
This commit is contained in:
Kostya Serebryany 2012-12-19 14:56:38 +00:00
parent 0f00de40dd
commit dcdeecb257
3 changed files with 16 additions and 1 deletions

View File

@ -32,9 +32,18 @@ namespace __asan {
struct AsanMapUnmapCallback {
void OnMap(uptr p, uptr size) const {
PoisonShadow(p, size, kAsanHeapLeftRedzoneMagic);
// Statistics.
AsanStats &thread_stats = asanThreadRegistry().GetCurrentThreadStats();
thread_stats.mmaps++;
thread_stats.mmaped += size;
// thread_stats.mmaped_by_size[size_class] += n_chunks;
}
void OnUnmap(uptr p, uptr size) const {
PoisonShadow(p, size, 0);
// Statistics.
AsanStats &thread_stats = asanThreadRegistry().GetCurrentThreadStats();
thread_stats.munmaps++;
thread_stats.munmaped += size;
}
};
@ -187,6 +196,9 @@ class Quarantine: public AsanChunkFifoList {
PushList(q);
PopAndDeallocateLoop(ms);
}
void SwallowThreadLocalCache(AllocatorCache *cache) {
// FIXME.
}
void BypassThreadLocalQuarantine(AsanChunk *m) {
SpinMutexLock l(&mutex_);
Push(m);
@ -420,6 +432,7 @@ AsanChunkView FindHeapChunkByAddress(uptr addr) {
void AsanThreadLocalMallocStorage::CommitBack() {
quarantine.SwallowThreadLocalQuarantine(this);
quarantine.SwallowThreadLocalCache(GetAllocatorCache(this));
}
SANITIZER_INTERFACE_ATTRIBUTE

View File

@ -37,6 +37,8 @@ struct AsanStats {
uptr realloced;
uptr mmaps;
uptr mmaped;
uptr munmaps;
uptr munmaped;
uptr mmaped_by_size[kNumberOfSizeClasses];
uptr malloced_by_size[kNumberOfSizeClasses];
uptr freed_by_size[kNumberOfSizeClasses];

View File

@ -123,7 +123,7 @@ uptr AsanThreadRegistry::GetCurrentAllocatedBytes() {
uptr AsanThreadRegistry::GetHeapSize() {
ScopedLock lock(&mu_);
UpdateAccumulatedStatsUnlocked();
return accumulated_stats_.mmaped;
return accumulated_stats_.mmaped - accumulated_stats_.munmaped;
}
uptr AsanThreadRegistry::GetFreeBytes() {