From: Pavel Charvat Date: Fri, 13 Feb 2015 12:43:16 +0000 (+0000) Subject: Mempool: mp_new(size) should not add size of chunk header before aligned to pages. X-Git-Tag: v6.3~7 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=497347e5c693bdb5f6c7fb5e4d4eddafcd7644c9;p=libucw.git 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. --- 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