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

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 20:29:13 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Andrei Homescu (ahomescu)

<details>
<summary>Changes</summary>

Don't use multiple tagged pages at the beginning of an allocation, since
it prevents using such allocations for memrefs, and mappings aren't
reused anyway since Trusty uses MapAllocatorNoCache.
Upstreamed from https://r.android.com/2537251.


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


1 Files Affected:

- (modified) compiler-rt/lib/scudo/standalone/secondary.h (+8-1) 


``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index c89e6a95f5a68a4..937dbde4452f2e8 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -114,7 +114,14 @@ template <typename Config> class MapAllocatorNoCache {
   }
 };
 
-static const uptr MaxUnusedCachePages = 4U;
+/*
+ * On Trusty we want to avoid splitting page-aligned allocations into
+ * multiple mappings, because it prevents using the allocation for memref.
+ * Using only 1 tagged page at the start of the allocation prevents
+ * reusing the mapping for slightly smaller allocations, but since Trusty
+ * uses MapAllocatorNoCache, it wouldn't reuse anyway.
+ */
+static const uptr MaxUnusedCachePages = SCUDO_TRUSTY ? 1U : 4U;
 
 template <typename Config>
 bool mapSecondary(const Options &Options, uptr CommitBase, uptr CommitSize,

``````````

</details>


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


More information about the llvm-commits mailing list