From eb6c1a05c893269c96e8469ab48948de04f45311 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Thu, 21 Oct 2021 11:35:25 +0100 Subject: [PATCH] Make chunk size at least the page size. On systems with larger than 16KiB page size, we have chunks that divide a page. This seems a little strange, and if we want to disable the pages backing a chunk, this is not possible. This change ensures the chunk is always at least a single page. --- src/mem/allocconfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mem/allocconfig.h b/src/mem/allocconfig.h index 660bc94..45937da 100644 --- a/src/mem/allocconfig.h +++ b/src/mem/allocconfig.h @@ -76,7 +76,8 @@ namespace snmalloc static constexpr size_t MIN_ALLOC_BITS = bits::ctz_const(MIN_ALLOC_SIZE); // Minimum slab size. - static constexpr size_t MIN_CHUNK_BITS = 14; + static constexpr size_t MIN_CHUNK_BITS = bits::max( + static_cast(14), bits::next_pow2_bits_const(OS_PAGE_SIZE)); static constexpr size_t MIN_CHUNK_SIZE = bits::one_at_bit(MIN_CHUNK_BITS); // Minimum number of objects on a slab