Originally, the requested chunk size was enlarged by the size of its metadata (~16 B)
and then in mmap version of mempools it was rounded up to the page size.
As the requested size itself is usually rounded to whole pages,
the chunk size was roughly by one page larger than expected;
still the whole space could have been used by mempools.
In non-mmap version (not used here), the effect might have been even worse,
as the rounding may be involved on the allocator level
and so the excessive memory cannot be used by mempools.
Now, usable size of chunks is a little smaller than requested,
but allocated area size corresponds to what was requested.
static size_t
mp_align_size(size_t size)
{
+ size = MAX(size, 64 + MP_CHUNK_TAIL);
#ifdef CONFIG_UCW_POOL_IS_MMAP
- return ALIGN_TO(size + MP_CHUNK_TAIL, CPU_PAGE_SIZE) - MP_CHUNK_TAIL;
+ return ALIGN_TO(size, CPU_PAGE_SIZE) - MP_CHUNK_TAIL;
#else
- return ALIGN_TO(size, CPU_STRUCT_ALIGN);
+ return ALIGN_TO(size, CPU_STRUCT_ALIGN) - MP_CHUNK_TAIL;
#endif
}