Comments on previous versions of this patch: http://dpdk.org/ml/archives/dev/2014-May/002297.html http://dpdk.org/ml/archives/dev/2014-June/003518.html
Additional changes from original to v3: * Reduce the minimum-sized block that we put on a free list when splitting a larger block, from 192 to 64. Although memory is plentiful, why waste 64 and 128-byte (plus overhead) blocks? -#define MIN_DATA_SIZE (CACHE_LINE_SIZE * 2) +#define MIN_DATA_SIZE (CACHE_LINE_SIZE) - if (old_elem_size <= MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE){ + if (old_elem_size < MALLOC_ELEM_OVERHEAD + MIN_DATA_SIZE){ - if (elem->size - new_size > MIN_DATA_SIZE + MALLOC_ELEM_OVERHEAD){ + if (elem->size - new_size >= MIN_DATA_SIZE + MALLOC_ELEM_OVERHEAD){ Changes from v2 to v3: * Change the size ranges of the five free lists per heap. The first list will effectively contain blocks of size [64,256]. - * heap->free_head[0] - (0 , 2^7] - * heap->free_head[1] - (2^7 , 2^9] - * heap->free_head[2] - (2^9 , 2^11] - * heap->free_head[3] - (2^11, 2^13] - * heap->free_head[4] - (2^13, MAX_SIZE] + * heap->free_head[0] - (0 , 2^8] + * heap->free_head[1] - (2^8 , 2^10] + * heap->free_head[2] - (2^10 ,2^12] + * heap->free_head[3] - (2^12, 2^14] + * heap->free_head[4] - (2^14, MAX_SIZE] - #define MALLOC_MINSIZE_LOG2 7 + #define MALLOC_MINSIZE_LOG2 8 * Fix typos and false assumptions in malloc unit tests. Even without linked-list enhancements to lib rte_malloc, malloc autotest fails every second (2nd) run.