Currently, all hugepages are allocated from lower VA address to
higher VA address, while malloc heap allocates from higher VA
address to lower VA address. This results in heap fragmentation
over time due to multiple reserves leaving small space below the
allocated elements.
Fix this by allocating VA memory from the top, thereby reducing
fragmentation and lowering overall memory usage.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
need = wa->n_segs;
/* try finding space in memseg list */
- cur_idx = rte_fbarray_find_next_n_free(&cur_msl->memseg_arr, 0, need);
+ cur_idx = rte_fbarray_find_prev_n_free(&cur_msl->memseg_arr,
+ cur_msl->memseg_arr.len - 1, need);
if (cur_idx < 0)
return 0;
start_idx = cur_idx;