[compiler-rt] [scudo] Avoid splitting aligned allocations on Trusty (PR #69281)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 14:35:12 PST 2024


================
@@ -122,18 +122,35 @@ bool mapSecondary(const Options &Options, uptr CommitBase, uptr CommitSize,
   Flags |= MAP_RESIZABLE;
   Flags |= MAP_ALLOWNOMEM;
 
-  const uptr MaxUnusedCacheBytes = MaxUnusedCachePages * getPageSizeCached();
+  const uptr PageSize = getPageSizeCached();
+  const uptr MaxUnusedCacheBytes = MaxUnusedCachePages * PageSize;
   if (useMemoryTagging<Config>(Options) && CommitSize > MaxUnusedCacheBytes) {
-    const uptr UntaggedPos = Max(AllocPos, CommitBase + MaxUnusedCacheBytes);
-    return MemMap.remap(CommitBase, UntaggedPos - CommitBase, "scudo:secondary",
-                        MAP_MEMTAG | Flags) &&
-           MemMap.remap(UntaggedPos, CommitBase + CommitSize - UntaggedPos,
-                        "scudo:secondary", Flags);
-  } else {
-    const uptr RemapFlags =
-        (useMemoryTagging<Config>(Options) ? MAP_MEMTAG : 0) | Flags;
-    return MemMap.remap(CommitBase, CommitSize, "scudo:secondary", RemapFlags);
+    if (SCUDO_TRUSTY) {
+      /*
----------------
ChiaHungDuan wrote:

Yep, that's fine. It'll be clear to see the intention for trusty.

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


More information about the llvm-commits mailing list