From 497347e5c693bdb5f6c7fb5e4d4eddafcd7644c9 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Fri, 13 Feb 2015 12:43:16 +0000 Subject: [PATCH] Mempool: mp_new(size) should not add size of chunk header before aligned to pages. ... so that mp_new(4096) allocates exactly one page, not two. --- ucw/mempool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ucw/mempool.c b/ucw/mempool.c index f9e268da..0bceb2bb 100644 --- a/ucw/mempool.c +++ b/ucw/mempool.c @@ -31,7 +31,8 @@ static size_t mp_align_size(size_t size) { #ifdef CONFIG_UCW_POOL_IS_MMAP - return ALIGN_TO(size + MP_CHUNK_TAIL, CPU_PAGE_SIZE) - MP_CHUNK_TAIL; + size = MAX(size, 64 + MP_CHUNK_TAIL); + return ALIGN_TO(size, CPU_PAGE_SIZE) - MP_CHUNK_TAIL; #else return ALIGN_TO(size, CPU_STRUCT_ALIGN); #endif -- 2.39.5