]> mj.ucw.cz Git - libucw.git/commitdiff
Mempool: mp_new(size) should not add size of chunk header before aligned to pages.
authorPavel Charvat <pchar@ucw.cz>
Fri, 13 Feb 2015 12:43:16 +0000 (12:43 +0000)
committerPavel Charvat <pchar@ucw.cz>
Fri, 13 Feb 2015 12:43:16 +0000 (12:43 +0000)
... so that mp_new(4096) allocates exactly one page, not two.

ucw/mempool.c

index f9e268dab5c9144745eb80b6bc735abcb9a30933..0bceb2bbbf90a1740be68aa3da7c1eeae3da3679 100644 (file)
@@ -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