[compiler-rt] [scudo] Add partial chunk heuristic to retrieval algorithm. (PR #104807)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 16:57:41 PDT 2024
================
@@ -336,6 +337,37 @@ TEST_F(MapAllocatorCacheTest, CacheOrder) {
MemMap.unmap();
}
+TEST_F(MapAllocatorCacheTest, PartialChunkHeuristicRetrievalTest) {
+ const scudo::uptr MaxUnusedCacheBytes = scudo::MaxUnusedCachePages * PageSize;
+ const scudo::uptr FragmentedBytes =
+ MaxUnusedCacheBytes +
+ scudo::roundDown(scudo::CachedBlock::ReleaseMemoryUpperBound, PageSize);
+
+ scudo::uptr MaxAllowedFragmentedBytes;
+ scudo::uptr EntryHeaderPos;
+ scudo::CachedBlock Entry;
+ scudo::MemMapT MemMap = allocate(PageSize + FragmentedBytes);
+ Cache->store(Options, MemMap.getBase(), MemMap.getCapacity(),
+ MemMap.getBase(), MemMap);
+
+ // FragmentedBytes > MaxAllowedFragmentedBytes so PageSize
+ // cannot be retrieved from the cache
+ MaxAllowedFragmentedBytes = 0;
+ Entry = Cache->retrieve(MaxAllowedFragmentedBytes, PageSize, PageSize, 0,
+ EntryHeaderPos);
----------------
ChiaHungDuan wrote:
How about
```suggestion
Entry = Cache->retrieve(/*MaxAllowedFragmentedBytes=*/0, PageSize, PageSize, 0,
EntryHeaderPos);
``
and just use `FragmentedBytes` below,
https://github.com/llvm/llvm-project/pull/104807
More information about the llvm-commits
mailing list