152 lines · plain
1//===-- allocator_config.def ------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines all the flags and types supported in Scudo. For optional10// flags and types, only explicitly define them when interested (i.e., unused11// optional flags or types can be skipped).12 13#ifndef BASE_REQUIRED_TEMPLATE_TYPE14#define BASE_REQUIRED_TEMPLATE_TYPE(...)15#endif16#ifndef BASE_OPTIONAL17#define BASE_OPTIONAL(...)18#endif19#ifndef PRIMARY_REQUIRED_TYPE20#define PRIMARY_REQUIRED_TYPE(...)21#endif22#ifndef PRIMARY_REQUIRED23#define PRIMARY_REQUIRED(...)24#endif25#ifndef PRIMARY_OPTIONAL26#define PRIMARY_OPTIONAL(...)27#endif28#ifndef PRIMARY_OPTIONAL_TYPE29#define PRIMARY_OPTIONAL_TYPE(...)30#endif31#ifndef SECONDARY_REQUIRED_TEMPLATE_TYPE32#define SECONDARY_REQUIRED_TEMPLATE_TYPE(...)33#endif34#ifndef SECONDARY_OPTIONAL35#define SECONDARY_OPTIONAL(...)36#endif37#ifndef SECONDARY_CACHE_OPTIONAL38#define SECONDARY_CACHE_OPTIONAL(...)39#endif40 41// BASE_REQUIRED_TEMPLATE_TYPE(NAME)42//43// Thread-Specific Data Registry used, shared or exclusive.44BASE_REQUIRED_TEMPLATE_TYPE(TSDRegistryT)45 46// Defines the type of Primary allocator to use.47BASE_REQUIRED_TEMPLATE_TYPE(PrimaryT)48 49// Defines the type of Secondary allocator to use.50BASE_REQUIRED_TEMPLATE_TYPE(SecondaryT)51 52// BASE_OPTIONAL(TYPE, NAME, DEFAULT)53//54// Indicates possible support for Memory Tagging.55BASE_OPTIONAL(const bool, MaySupportMemoryTagging, false)56 57// Disable the quarantine code.58BASE_OPTIONAL(const bool, QuarantineDisabled, false)59 60// If set to true, malloc_usable_size returns the exact size of the allocation.61// If set to false, return the total available size in the allocation.62BASE_OPTIONAL(const bool, ExactUsableSize, true)63 64// PRIMARY_REQUIRED_TYPE(NAME)65//66// SizeClassMap to use with the Primary.67PRIMARY_REQUIRED_TYPE(SizeClassMap)68 69// PRIMARY_REQUIRED(TYPE, NAME)70//71// Log2 of the size of a size class region, as used by the Primary.72PRIMARY_REQUIRED(const uptr, RegionSizeLog)73 74// Conceptually, a region will be divided into groups based on the address75// range. Each allocation consumes blocks in the same group until exhaustion76// then it pops out blocks in a new group. Therefore, `GroupSizeLog` is always77// smaller or equal to `RegionSizeLog`. Note that `GroupSizeLog` needs to be78// equal to `RegionSizeLog` for SizeClassAllocator32 because of certain79// constraints.80PRIMARY_REQUIRED(const uptr, GroupSizeLog)81 82// Call map for user memory with at least this size. Only used with primary64.83PRIMARY_REQUIRED(const uptr, MapSizeIncrement)84 85// Defines the minimal & maximal release interval that can be set.86PRIMARY_REQUIRED(const s32, MinReleaseToOsIntervalMs)87PRIMARY_REQUIRED(const s32, MaxReleaseToOsIntervalMs)88 89// PRIMARY_OPTIONAL(TYPE, NAME, DEFAULT)90//91 92// Enables/disables primary block caching. Batch class still caches.93PRIMARY_OPTIONAL(const bool, EnableBlockCache, true)94 95// The scale of a compact pointer. E.g., Ptr = Base + (CompactPtr << Scale).96PRIMARY_OPTIONAL(const uptr, CompactPtrScale, SCUDO_MIN_ALIGNMENT_LOG)97 98// Indicates support for offsetting the start of a region by a random number of99// pages. This is only used if `EnableContiguousRegions` is enabled.100PRIMARY_OPTIONAL(const bool, EnableRandomOffset, false)101PRIMARY_OPTIONAL(const s32, DefaultReleaseToOsIntervalMs, INT32_MIN)102 103// When `EnableContiguousRegions` is true, all regions will be be arranged in104// adjacency. This will reduce the fragmentation caused by region allocations105// but may require a huge amount of contiguous pages at initialization.106PRIMARY_OPTIONAL(const bool, EnableContiguousRegions, true)107 108// PRIMARY_OPTIONAL_TYPE(NAME, DEFAULT)109//110// Use condition variable to shorten the waiting time of refillment of111// freelist. Note that this depends on the implementation of condition112// variable on each platform and the performance may vary so that it does not113// guarantee a performance benefit.114PRIMARY_OPTIONAL_TYPE(ConditionVariableT, ConditionVariableDummy)115 116// Defines the type and scale of a compact pointer. A compact pointer can117// be understood as the offset of a pointer within the region it belongs118// to, in increments of a power-of-2 scale. See `CompactPtrScale` also.119PRIMARY_OPTIONAL_TYPE(CompactPtrT, uptr)120 121// SECONDARY_REQUIRED_TEMPLATE_TYPE(NAME)122//123// Defines the type of Secondary Cache to use.124SECONDARY_REQUIRED_TEMPLATE_TYPE(CacheT)125 126// SECONDARY_OPTIONAL(TYPE, NAME, DEFAULT)127//128// Add one guard page at the front and back for each allocation.129SECONDARY_OPTIONAL(const bool, EnableGuardPages, true)130 131// SECONDARY_CACHE_OPTIONAL(TYPE, NAME, DEFAULT)132//133// Defines the type of cache used by the Secondary. Some additional134// configuration entries can be necessary depending on the Cache.135SECONDARY_CACHE_OPTIONAL(const u32, EntriesArraySize, 0)136SECONDARY_CACHE_OPTIONAL(const u32, QuarantineSize, 0)137SECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntriesCount, 0)138SECONDARY_CACHE_OPTIONAL(const uptr, DefaultMaxEntrySize, 0)139SECONDARY_CACHE_OPTIONAL(const s32, MinReleaseToOsIntervalMs, INT32_MIN)140SECONDARY_CACHE_OPTIONAL(const s32, MaxReleaseToOsIntervalMs, INT32_MAX)141SECONDARY_CACHE_OPTIONAL(const s32, DefaultReleaseToOsIntervalMs, INT32_MIN)142 143#undef SECONDARY_CACHE_OPTIONAL144#undef SECONDARY_OPTIONAL145#undef SECONDARY_REQUIRED_TEMPLATE_TYPE146#undef PRIMARY_OPTIONAL_TYPE147#undef PRIMARY_OPTIONAL148#undef PRIMARY_REQUIRED149#undef PRIMARY_REQUIRED_TYPE150#undef BASE_OPTIONAL151#undef BASE_REQUIRED_TEMPLATE_TYPE152