Skip to content

[scudo] Mitigate the overhead in cache storing when MTE enabled #66717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChiaHungDuan
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2023

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

Changes

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 --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;

@ChiaHungDuan ChiaHungDuan requested a review from hctim September 18, 2023 22:44
@ChiaHungDuan
Copy link
Contributor Author

This is another way to mitigate the problem mentioned in #65942. Now it's only a RFC change.

@andersdellien-arm
Copy link

As far as I can tell, this would solve the same problem that #65942 is addressing. So the performance benefit would be the same

@ChiaHungDuan
Copy link
Contributor Author

As far as I can tell, this would solve the same problem that #65942 is addressing. So the performance benefit would be the same

Right, this is supposed to do the same thing as setting the release interval and has no impact on non-MTE path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants