a3cf59f56c
Currently, the memory allocated by rte_malloc() also introduced more than 64 bytes overhead. It means when allocate 64 bytes memory, the real cost in memory maybe double. And the libc malloc() overhead is 16 bytes, If users try allocating millions of small memory blocks, the overhead costing maybe huge. And save the memory pointer will also be quite expensive. Indexed memory pool is introduced to save the memory for allocating huge amount of small memory blocks. The indexed memory uses trunk and bitmap to manage the memory entries. While the pool is empty, the trunk slot contains memory entry array will be allocated firstly. The bitmap in the trunk records the entry allocation. The offset of trunk slot in the pool and the offset of memory entry in the trunk slot compose the index for the memory entry. So, by the index, it will be very easy to address the memory of the entry. User saves the 32 bits index for the memory resource instead of the 64 bits pointer. User should create different pools for allocating different size of small memory block. It means one pool provides one fixed size of small memory blocked allocating. Signed-off-by: Suanming Mou <suanmingm@mellanox.com> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>