[compiler-rt] [scudo] Mitigate the overhead in cache storing when MTE enabled (PR #66717)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 15:44:47 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

<details>
<summary>Changes</summary>

mapSecondary() requires two mmap calls and may impact the performance in some cases that use secondary allocator heavily. Only use setMemoryPermission to reduce the time in contention of memory system calls.

---
Full diff: https://github.com/llvm/llvm-project/pull/66717.diff


1 Files Affected:

- (modified) compiler-rt/lib/scudo/standalone/secondary.h (+3-11) 


``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index d0890d1c5e2d3d5..c4192bfd45bba2e 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -210,18 +210,10 @@ template <typename Config> class MapAllocatorCache {
     Entry.MemMap = H->MemMap;
     Entry.Time = Time;
     if (useMemoryTagging<Config>(Options)) {
-      if (Interval == 0 && !SCUDO_FUCHSIA) {
-        // Release the memory and make it inaccessible at the same time by
-        // creating a new MAP_NOACCESS mapping on top of the existing mapping.
-        // Fuchsia does not support replacing mappings by creating a new mapping
-        // on top so we just do the two syscalls there.
+      if (Interval == 0)
         Entry.Time = 0;
-        mapSecondary<Config>(Options, Entry.CommitBase, Entry.CommitSize,
-                             Entry.CommitBase, MAP_NOACCESS, Entry.MemMap);
-      } else {
-        Entry.MemMap.setMemoryPermission(Entry.CommitBase, Entry.CommitSize,
-                                         MAP_NOACCESS);
-      }
+      Entry.MemMap.setMemoryPermission(Entry.CommitBase, Entry.CommitSize,
+                                       MAP_NOACCESS);
     } else if (Interval == 0) {
       Entry.MemMap.releasePagesToOS(Entry.CommitBase, Entry.CommitSize);
       Entry.Time = 0;

``````````

</details>


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


More information about the llvm-commits mailing list