[PATCH] D39131: [Sanitizers] Add total primary allocator RSS to allocator report.

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 11:00:59 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL316356: [Sanitizers] Add total primary allocator RSS to allocator report. (authored by alekseyshl).

Repository:
  rL LLVM

https://reviews.llvm.org/D39131

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h


Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -241,22 +241,28 @@
   }
 
   void PrintStats() {
+    uptr rss_stats[kNumClasses];
+    for (uptr class_id = 0; class_id < kNumClasses; class_id++)
+      rss_stats[class_id] = SpaceBeg() + kRegionSize * class_id;
+    GetMemoryProfile(FillMemoryProfile, rss_stats, kNumClasses);
+
     uptr total_mapped = 0;
+    uptr total_rss = 0;
     uptr n_allocated = 0;
     uptr n_freed = 0;
     for (uptr class_id = 1; class_id < kNumClasses; class_id++) {
       RegionInfo *region = GetRegionInfo(class_id);
-      total_mapped += region->mapped_user;
+      if (region->mapped_user != 0) {
+        total_mapped += region->mapped_user;
+        total_rss += rss_stats[class_id];
+      }
       n_allocated += region->stats.n_allocated;
       n_freed += region->stats.n_freed;
     }
-    Printf("Stats: SizeClassAllocator64: %zdM mapped in %zd allocations; "
-           "remains %zd\n",
-           total_mapped >> 20, n_allocated, n_allocated - n_freed);
-    uptr rss_stats[kNumClasses];
-    for (uptr class_id = 0; class_id < kNumClasses; class_id++)
-      rss_stats[class_id] = SpaceBeg() + kRegionSize * class_id;
-    GetMemoryProfile(FillMemoryProfile, rss_stats, kNumClasses);
+
+    Printf("Stats: SizeClassAllocator64: %zdM mapped (%zdM rss) in "
+           "%zd allocations; remains %zd\n", total_mapped >> 20,
+           total_rss >> 20, n_allocated, n_allocated - n_freed);
     for (uptr class_id = 1; class_id < kNumClasses; class_id++)
       PrintStats(class_id, rss_stats[class_id]);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39131.119902.patch
Type: text/x-patch
Size: 1811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171023/eb8ce259/attachment.bin>


More information about the llvm-commits mailing list