New configuration of slab sizes for OE.

This commit is contained in:
Matthew Parkinson
2020-06-18 11:08:33 +01:00
committed by Matthew Parkinson
parent 26949de089
commit e393ac882f
3 changed files with 29 additions and 4 deletions

View File

@@ -50,6 +50,15 @@ namespace snmalloc
#endif
;
// Specifies even smaller slab and super slab sizes for open enclave.
static constexpr size_t REALLY_ADDRESS_SPACE_CONSTRAINED =
#ifdef IS_REALLY_ADDRESS_SPACE_CONSTRAINED
true
#else
false
#endif
;
static constexpr size_t RESERVE_MULTIPLE =
#ifdef USE_RESERVE_MULTIPLE
USE_RESERVE_MULTIPLE
@@ -100,14 +109,17 @@ namespace snmalloc
static constexpr size_t MIN_ALLOC_BITS = bits::ctz_const(MIN_ALLOC_SIZE);
// Slabs are 64 KiB unless constrained to 16 KiB.
static constexpr size_t SLAB_BITS = ADDRESS_SPACE_CONSTRAINED ? 14 : 16;
static constexpr size_t SLAB_BITS = REALLY_ADDRESS_SPACE_CONSTRAINED ?
13 :
(ADDRESS_SPACE_CONSTRAINED ? 14 : 16);
static constexpr size_t SLAB_SIZE = 1 << SLAB_BITS;
static constexpr size_t SLAB_MASK = ~(SLAB_SIZE - 1);
// Superslabs are composed of this many slabs. Slab offsets are encoded as
// a byte, so the maximum count is 256. This must be a power of two to
// allow fast masking to find a superslab start address.
static constexpr size_t SLAB_COUNT_BITS = ADDRESS_SPACE_CONSTRAINED ? 6 : 8;
static constexpr size_t SLAB_COUNT_BITS =
REALLY_ADDRESS_SPACE_CONSTRAINED ? 5 : (ADDRESS_SPACE_CONSTRAINED ? 6 : 8);
static constexpr size_t SLAB_COUNT = 1 << SLAB_COUNT_BITS;
static constexpr size_t SUPERSLAB_SIZE = SLAB_SIZE * SLAB_COUNT;
static constexpr size_t SUPERSLAB_MASK = ~(SUPERSLAB_SIZE - 1);

View File

@@ -1,4 +1,7 @@
#undef IS_ADDRESS_SPACE_CONSTRAINED
// Remove parameters feed from test harness
#undef ADDRESS_SPACE_CONSTRAINED
#undef REALLY_ADDRESS_SPACE_CONSTRAINED
#define SNMALLOC_NAME_MANGLE(a) host_##a
#define NO_BOOTSTRAP_ALLOCATOR
#define SNMALLOC_EXPOSE_PAGEMAP