Skip to content

eal/malloc: fix wrong heap initialization over multiple memsegs

Gowrishankar dpdk-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2eal/malloc: merge malloc_elems in heap if they are contiguouslib/librte_eal/common/malloc_heap.c+29 -13 replies
2/2eal/malloc: fix heap index to correctly insert memseglib/librte_eal/common/malloc_heap.c+22 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] eal/malloc: fix wrong heap initialization over multiple memsegs

From: Gowrishankar Muthukrishnan <[email protected]>

When there are multiple memsegs (each per hugepage), there are couple of problems observed:

1. Same heap size index is always chosen to add new malloc_elems again and again, while there is an increasing heap size actually. Hence, when there is memalloc request for size *more than* elem->size available in free heap, malloc_heap_alloc would fail. In elem_start_pt(), we are actually relying on elem->size at the best, for finding suitable element, which is lower than requested size, in this case.

Hence, patch 1 in this series addresses this by merging contiguous malloc_elem (by virt addresses), so that there is better chance of finding suitable elem for the requested size.

2. Even after resizing the heap malloc_elems, its free_head index is still the same, as the memsegs are just added in every malloc_ elem. If larger memory is requested in rte_malloc, in a way that, heap index of requested size is beyond the slot where the entire heap is available, malloc_heap_alloc would fail. Because, at the time of heap init, only the lower index is always chosen to fill up memsegs. Hence, patch 2 addresses this by moving the list of malloc_elems into new slot in heap, as its size grows.

We encountered these situations as we run ip_reassembly example app, when multiple segments are created in VA (when overcommit hugepages set in powerpc arch).

These problems are found only in the current releases (until v18.05 which carries new implementation for dynamic memory allocation). These patches are tested with unit tests as well as some of the examples apps. I request more testing if possible, on other archs as these are problems in available LTS codes as well.

Gowrishankar Muthukrishnan (2):
eal/malloc: merge malloc_elems in heap if they are contiguous eal/malloc: fix heap index to correctly insert memseg

 lib/librte_eal/common/malloc_heap.c | 52 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1