[compiler-rt] [scudo] Update secondary cache time-based release logic. (PR #107507)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 11:57:42 PDT 2024


================
@@ -590,35 +596,36 @@ class MapAllocatorCache {
     }
   }
 
-  void releaseIfOlderThan(CachedBlock &Entry, u64 Time) REQUIRES(Mutex) {
-    if (!Entry.isValid() || !Entry.Time)
-      return;
-    if (Entry.Time > Time) {
-      if (OldestTime == 0 || Entry.Time < OldestTime)
-        OldestTime = Entry.Time;
-      return;
-    }
+  inline void release(CachedBlock &Entry) {
+    DCHECK(Entry.Time != 0);
     Entry.MemMap.releaseAndZeroPagesToOS(Entry.CommitBase, Entry.CommitSize);
     Entry.Time = 0;
   }
 
   void releaseOlderThan(u64 Time) EXCLUDES(Mutex) {
     ScopedLock L(Mutex);
-    if (!EntriesCount || OldestTime == 0 || OldestTime > Time)
+    if (!EntriesCount)
       return;
-    OldestTime = 0;
-    for (uptr I = 0; I < Config::getQuarantineSize(); I++)
-      releaseIfOlderThan(Quarantine[I], Time);
-    for (uptr I = 0; I < Config::getEntriesArraySize(); I++)
-      releaseIfOlderThan(Entries[I], Time);
-  }
 
+    for (uptr I = 0; I < Config::getQuarantineSize(); I++) {
----------------
ChiaHungDuan wrote:

hmmm, I think we should avoid scan the quarantine entries here. I think we can have a function like

```
bool IsQuarantineEnabled() {
  return useMemoryTagging<Config>(Options) && QuarantinePos != -1U;
}
```
to bypass scanning the quarantine entries. It doesn't need to be done in this CL by the way.

https://github.com/llvm/llvm-project/pull/107507


More information about the llvm-commits mailing list