[compiler-rt] [compiler-rt][sanitizer_common] Increase min user-map/freearray round… (PR #73600)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 17:46:36 PST 2023


https://github.com/PiJoules created https://github.com/llvm/llvm-project/pull/73600

…ing size

About 90% of the time when running scudo tests on fuchsia+riscv with asan instrumentation, we will be unable to map the arena for scudo's primary allocator. We have enough space, but much of the existing allocations are fragmented enough such that we can't allocate that large enough contiguous space. This reduces fragmentation more by increase min allocation rounding for user-map and freearray in the primary allocator.

Note that changing these values doesn't have a functional effect on the actual size of the user-map or freearray portions of a region. Those are toggled by different constants. This will reduce the number of times mmap is called and reduce the number of fragments.

Locally, I've been able to run the scudo tests under asan-instrumentation on riscv 39-bit vma and haven't run into the `SCUDO ERROR: zx_vmar_map` error.

>From c27b905d2def7df41ca13bc729c00e4b889c2108 Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Tue, 28 Nov 2023 01:28:13 +0000
Subject: [PATCH] [compiler-rt][sanitizer_common] Increase min
 user-map/freearray rounding size

About 90% of the time when running scudo tests on fuchsia+riscv with
asan instrumentation, we will be unable to map the arena for scudo's
primary allocator. We have enough space, but much of the existing
allocations are fragmented enough such that we can't allocate that large
enough contiguous space. This reduces fragmentation more by increase min
allocation rounding for user-map and freearray in the primary allocator.

Note that changing these values doesn't have a functional effect on the
actual size of the user-map or freearray portions of a region. Those are
toggled by different constants. This will reduce the number
of times mmap is called and reduce the number of fragments.

Locally, I've been able to run the scudo tests under
asan-instrumentation on riscv 39-bit vma and haven't run into the `SCUDO
ERROR: zx_vmar_map` error.
---
 .../lib/sanitizer_common/sanitizer_allocator_primary64.h      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index d77bc05b780203b..34a64f26478fd5e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -641,11 +641,11 @@ class SizeClassAllocator64 {
   // kRegionSize must be <= 2^36, see CompactPtrT.
   COMPILER_CHECK((kRegionSize) <= (1ULL << (SANITIZER_WORDSIZE / 2 + 4)));
   // Call mmap for user memory with at least this size.
-  static const uptr kUserMapSize = 1 << 16;
+  static const uptr kUserMapSize = 1 << 18;
   // Call mmap for metadata memory with at least this size.
   static const uptr kMetaMapSize = 1 << 16;
   // Call mmap for free array memory with at least this size.
-  static const uptr kFreeArrayMapSize = 1 << 16;
+  static const uptr kFreeArrayMapSize = 1 << 18;
 
   atomic_sint32_t release_to_os_interval_ms_;
 



More information about the llvm-commits mailing list