From c19c8aec88a3f11265303e0c124e006a3b803586 Mon Sep 17 00:00:00 2001 From: Avi Kivity <avi@cloudius-systems.com> Date: Thu, 15 Aug 2013 14:56:44 +0300 Subject: [PATCH] mempool: workaround for unaligned allocations An allocation that is larger than half a page, but smaller than a page, will end up badly aligned. Work around it by using the large allocators for objects larger than half a page. This is wasteful and slow but at least it works. Later we can improve this by moving the slab header to the end of the page, so it doesn't interfere with alignment. --- core/mempool.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/mempool.cc b/core/mempool.cc index 23ae2dc22..012b56c61 100644 --- a/core/mempool.cc +++ b/core/mempool.cc @@ -158,7 +158,8 @@ pool::~pool() { } -const size_t pool::max_object_size = page_size - sizeof(pool::page_header); +// FIXME: handle larger sizes better, while preserving alignment: +const size_t pool::max_object_size = page_size / 2; const size_t pool::min_object_size = sizeof(pool::free_object); pool::page_header* pool::to_header(free_object* object) -- GitLab