mem: allocate in reverse to reduce fragmentation

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>
This commit is contained in:
Anatoly Burakov 2018-06-11 21:55:42 +01:00 committed by Thomas Monjalon
parent 7985860c18
commit 179f916e88

View File

@ -703,7 +703,8 @@ alloc_seg_walk(const struct rte_memseg_list *msl, void *arg)
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;