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

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 11:43:33 PDT 2017


alekseyshl created this revision.
Herald added a subscriber: kubamracek.

.


https://reviews.llvm.org/D39131

Files:
  lib/sanitizer_common/sanitizer_allocator_primary64.h


Index: lib/sanitizer_common/sanitizer_allocator_primary64.h
===================================================================
--- lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -234,22 +234,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.119675.patch
Type: text/x-patch
Size: 1757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171020/3b451145/attachment.bin>


More information about the llvm-commits mailing list