Skip to content

Commit e393ac8

Browse files
committed
New configuration of slab sizes for OE.
1 parent 26949de commit e393ac8

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ macro(warnings_high)
5151
endif()
5252
endmacro()
5353

54+
macro(oe_simulate target)
55+
target_compile_definitions(${target} PRIVATE IS_REALLY_ADDRESS_SPACE_CONSTRAINED)
56+
endmacro()
57+
5458
macro(clangformat_targets)
5559
# The clang-format tool is installed under a variety of different names. Try
5660
# to find a sensible one. Only look for versions 9 explicitly - we don't
@@ -244,6 +248,9 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
244248
add_shim(snmallocshim SHARED ${SHARED_FILES})
245249
add_shim(snmallocshim-1mib SHARED ${SHARED_FILES})
246250
target_compile_definitions(snmallocshim-1mib PRIVATE IS_ADDRESS_SPACE_CONSTRAINED)
251+
# Build a shim with some settings from oe.
252+
add_shim(snmallocshim-oe SHARED ${SHARED_FILES})
253+
oe_simulate(snmallocshim-oe)
247254
endif()
248255

249256
if(SNMALLOC_RUST_SUPPORT)
@@ -260,7 +267,7 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
260267
foreach(TEST_CATEGORY ${TEST_CATEGORIES})
261268
subdirlist(TESTS ${TESTDIR}/${TEST_CATEGORY})
262269
foreach(TEST ${TESTS})
263-
foreach(SUPER_SLAB_SIZE 1;16)
270+
foreach(SUPER_SLAB_SIZE 1;16;oe)
264271
unset(SRC)
265272
aux_source_directory(${TESTDIR}/${TEST_CATEGORY}/${TEST} SRC)
266273
set(TESTNAME "${TEST_CATEGORY}-${TEST}-${SUPER_SLAB_SIZE}")
@@ -269,6 +276,9 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
269276
if (${SUPER_SLAB_SIZE} EQUAL 1)
270277
target_compile_definitions(${TESTNAME} PRIVATE IS_ADDRESS_SPACE_CONSTRAINED)
271278
endif()
279+
if (${SUPER_SLAB_SIZE} EQUAL oe)
280+
oe_simulate(${TESTNAME})
281+
endif()
272282
target_link_libraries(${TESTNAME} snmalloc_lib)
273283
if (${TEST} MATCHES "release-.*")
274284
message(STATUS "Adding test: ${TESTNAME} only for release configs")

src/mem/allocconfig.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ namespace snmalloc
5050
#endif
5151
;
5252

53+
// Specifies even smaller slab and super slab sizes for open enclave.
54+
static constexpr size_t REALLY_ADDRESS_SPACE_CONSTRAINED =
55+
#ifdef IS_REALLY_ADDRESS_SPACE_CONSTRAINED
56+
true
57+
#else
58+
false
59+
#endif
60+
;
61+
5362
static constexpr size_t RESERVE_MULTIPLE =
5463
#ifdef USE_RESERVE_MULTIPLE
5564
USE_RESERVE_MULTIPLE
@@ -100,14 +109,17 @@ namespace snmalloc
100109
static constexpr size_t MIN_ALLOC_BITS = bits::ctz_const(MIN_ALLOC_SIZE);
101110

102111
// Slabs are 64 KiB unless constrained to 16 KiB.
103-
static constexpr size_t SLAB_BITS = ADDRESS_SPACE_CONSTRAINED ? 14 : 16;
112+
static constexpr size_t SLAB_BITS = REALLY_ADDRESS_SPACE_CONSTRAINED ?
113+
13 :
114+
(ADDRESS_SPACE_CONSTRAINED ? 14 : 16);
104115
static constexpr size_t SLAB_SIZE = 1 << SLAB_BITS;
105116
static constexpr size_t SLAB_MASK = ~(SLAB_SIZE - 1);
106117

107118
// Superslabs are composed of this many slabs. Slab offsets are encoded as
108119
// a byte, so the maximum count is 256. This must be a power of two to
109120
// allow fast masking to find a superslab start address.
110-
static constexpr size_t SLAB_COUNT_BITS = ADDRESS_SPACE_CONSTRAINED ? 6 : 8;
121+
static constexpr size_t SLAB_COUNT_BITS =
122+
REALLY_ADDRESS_SPACE_CONSTRAINED ? 5 : (ADDRESS_SPACE_CONSTRAINED ? 6 : 8);
111123
static constexpr size_t SLAB_COUNT = 1 << SLAB_COUNT_BITS;
112124
static constexpr size_t SUPERSLAB_SIZE = SLAB_SIZE * SLAB_COUNT;
113125
static constexpr size_t SUPERSLAB_MASK = ~(SUPERSLAB_SIZE - 1);

src/test/func/two_alloc_types/alloc2.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#undef IS_ADDRESS_SPACE_CONSTRAINED
1+
// Remove parameters feed from test harness
2+
#undef ADDRESS_SPACE_CONSTRAINED
3+
#undef REALLY_ADDRESS_SPACE_CONSTRAINED
4+
25
#define SNMALLOC_NAME_MANGLE(a) host_##a
36
#define NO_BOOTSTRAP_ALLOCATOR
47
#define SNMALLOC_EXPOSE_PAGEMAP

0 commit comments

Comments
 (0)