[compiler-rt] 0e93c4a - [scudo] SizeClassAllocator64: dispatch all the classes in init()

Fabio D'Urso via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 08:14:10 PDT 2023


Author: Fabio D'Urso
Date: 2023-06-30T17:13:41+02:00
New Revision: 0e93c4a5fd5825a16fd3c00f9f7942ec88412771

URL: https://github.com/llvm/llvm-project/commit/0e93c4a5fd5825a16fd3c00f9f7942ec88412771
DIFF: https://github.com/llvm/llvm-project/commit/0e93c4a5fd5825a16fd3c00f9f7942ec88412771.diff

LOG: [scudo] SizeClassAllocator64: dispatch all the classes in init()

This will make it easier to verify in a future patch that the ReservedMemory object has been fully dispatched.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D153019

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/primary64.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index ab75f19d8a18de..e6cd120ca07cf3 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -132,6 +132,10 @@ template <typename Config> class SizeClassAllocator64 {
       else
         Region->TryReleaseThreshold = PageSize;
       Region->ReleaseInfo.LastReleaseAtNs = Time;
+
+      Region->MemMapInfo.MemMap = ReservedMemory.dispatch(
+          PrimaryBase + (I << Config::Primary::RegionSizeLog), RegionSize);
+      CHECK(Region->MemMapInfo.MemMap.isAllocated());
     }
     shuffle(RegionInfoArray, NumClasses, &Seed);
 
@@ -822,12 +826,6 @@ template <typename Config> class SizeClassAllocator64 {
         Region->Exhausted = true;
         return nullptr;
       }
-      // TODO: Consider allocating MemMap in init().
-      if (!Region->MemMapInfo.MemMap.isAllocated()) {
-        Region->MemMapInfo.MemMap = ReservedMemory.dispatch(
-            getRegionBaseByClassId(ClassId), RegionSize);
-      }
-      DCHECK(Region->MemMapInfo.MemMap.isAllocated());
 
       if (UNLIKELY(!Region->MemMapInfo.MemMap.remap(
               RegionBeg + MappedUser, MapSize, "scudo:primary",


        


More information about the llvm-commits mailing list