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

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 14:45:18 PDT 2023


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

>From e425a559525d945f150c6b2390893694d19ff560 Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Mon, 18 Sep 2023 22:34:42 +0000
Subject: [PATCH 1/2] [scudo] Mitigate the overhead in cache storing when MTE
 enabled

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.
---
 compiler-rt/lib/scudo/standalone/secondary.h | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

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;

>From 14936a4fb7c620ef95260ea3c2b109047f2bd07d Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Tue, 19 Sep 2023 21:42:49 +0000
Subject: [PATCH 2/2] [Github] Add compiler-rt:scudo label to scudo prs

---
 .github/new-prs-labeler.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.github/new-prs-labeler.yml b/.github/new-prs-labeler.yml
index 50b962a463eb28f..9deb167f1e1746e 100644
--- a/.github/new-prs-labeler.yml
+++ b/.github/new-prs-labeler.yml
@@ -90,6 +90,10 @@ compiler-rt:sanitizer:
   - compiler-rt/lib/scudo/**
   - compiler-rt/test/scudo/**
 
+compiler-rt:scudo:
+  - compiler-rt/lib/scudo/**
+  - compiler-rt/test/scudo/**
+
 xray:
   - llvm/tools/llvm-xray/**
   - compiler-rt/*/xray/**



More information about the llvm-commits mailing list