[compiler-rt] [scudo] Update secondary cache released pages bound. (PR #106466)

Joshua Baehring via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 16:10:01 PDT 2024


https://github.com/JoshuaMBa updated https://github.com/llvm/llvm-project/pull/106466

>From 7868fc9f9d73bb14f42164c775ab76881c399552 Mon Sep 17 00:00:00 2001
From: Joshua Baehring <josh.baehring at yale.edu>
Date: Wed, 28 Aug 2024 13:35:48 -0400
Subject: [PATCH] [scudo] Update secondary cache released pages bound.

`MaxReleasedCachePages` has been set to 4.
---
 compiler-rt/lib/scudo/standalone/secondary.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index fba21c3cb6a09d..5d1be0a9fd5cea 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -79,8 +79,7 @@ struct CachedBlock {
   //        it suggests that beyond 4 pages, the release execution time is
   //        longer than the map execution time. In this way, the default
   //        is dependent on the platform.
-  //    TODO: set MaxReleasedCachePages back to 4U
-  static constexpr uptr MaxReleasedCachePages = 0U;
+  static constexpr uptr MaxReleasedCachePages = 4U;
 
   uptr CommitBase = 0;
   uptr CommitSize = 0;
@@ -389,17 +388,14 @@ class MapAllocatorCache {
         const uptr HeaderPos = AllocPos - HeadersSize;
         const uptr MaxAllowedFragmentedBytes =
             MaxAllowedFragmentedPages * PageSize;
-        if (HeaderPos > CommitBase + CommitSize)
+        if (HeaderPos > CommitBase + CommitSize || HeaderPos < CommitBase)
           continue;
-        // TODO: Remove AllocPos > CommitBase + MaxAllowedFragmentedBytes
-        // and replace with Diff > MaxAllowedFragmentedBytes
-        if (HeaderPos < CommitBase ||
-            AllocPos > CommitBase + MaxAllowedFragmentedBytes) {
-          continue;
-        }
 
         const uptr Diff = roundDown(HeaderPos, PageSize) - CommitBase;
 
+        if (Diff > MaxAllowedFragmentedBytes)
+          continue;
+
         // Keep track of the smallest cached block
         // that is greater than (AllocSize + HeaderSize)
         if (Diff >= MinDiff)



More information about the llvm-commits mailing list