Problems with lib rte_malloc: 1. Rte_malloc searches a heap's entire free list looking for the best fit, resulting in linear complexity. 2. Heaps store free blocks in a singly-linked list, resulting in linear complexity when rte_free needs to remove an adjacent block. 3. The library inserts and removes free blocks with ad hoc, in-line code, rather than using linked-list functions or macros. 4. The library wastes potential small blocks of size 64 and 128 bytes (plus overhead of 64 bytes) as padding when reusing free blocks or resizing allocated blocks. This patch addresses those problems as follows: 1. Replace single free list with a handful of free lists. Each free list contains blocks of a specified size range, for example: list[0]: (0 , 2^8] list[1]: (2^8 , 2^10] list[2]: (2^10, 2^12] list[3]: (2^12, 2^14] list[4]: (2^14, MAX_SIZE] When allocating a block, start at the first list that can contain a big enough block. Search subsequent lists, if necessary. Terminate the search as soon as we find a block that is big enough. 2. Use doubly-linked lists, so that we can remove free blocks in constant time. 3. Use BSD LIST macros, as defined in sys/queue.h and the QUEUE(3) man page. 4. Change code to utilize small blocks of data size 64 and 128, when splitting larger blocks. Signed-off-by: Robert Sanford <rsanford2@gmail.com> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Description
No description provided
Languages
C
99.1%
Meson
0.5%
Python
0.2%
Shell
0.1%