]> git.droids-corp.org - dpdk.git/commitdiff
malloc: fix allocation of almost hugepage size
authorFidaullah Noonari <fidaullah.noonari@emumba.com>
Wed, 25 May 2022 05:18:37 +0000 (10:18 +0500)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 23 Jun 2022 11:40:50 +0000 (13:40 +0200)
If called to allocate memory of size is between multiple of hugepage
size minus malloc_header_len and hugepage size, rte_malloc fails.

This fix replaces malloc_elem_trailer_len with malloc_elem_overhead in
try_expand_heap() to include malloc_elem_header_len when calculating
n_seg.

Bugzilla ID: 800
Fixes: 07dcbfe0101f ("malloc: support multiprocess memory hotplug")
Cc: stable@dpdk.org
Signed-off-by: Fidaullah Noonari <fidaullah.noonari@emumba.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
lib/eal/common/malloc_heap.c
lib/eal/common/malloc_mp.c

index a3d26fcbea78cdf6980391d7d83d92dd20bf8ed3..27a52266ada751c8a9fc4c73389b27d425592345 100644 (file)
@@ -403,7 +403,7 @@ try_expand_heap_primary(struct malloc_heap *heap, uint64_t pg_sz,
        bool callback_triggered = false;
 
        alloc_sz = RTE_ALIGN_CEIL(align + elt_size +
-                       MALLOC_ELEM_TRAILER_LEN, pg_sz);
+                       MALLOC_ELEM_OVERHEAD, pg_sz);
        n_segs = alloc_sz / pg_sz;
 
        /* we can't know in advance how many pages we'll need, so we malloc */
index 207b90847ed5f062bbb7168a2177818e17020319..2b8eb510679edde82a1147d6410f2331bf598c5a 100644 (file)
@@ -250,7 +250,7 @@ handle_alloc_request(const struct malloc_mp_req *m,
        }
 
        alloc_sz = RTE_ALIGN_CEIL(ar->align + ar->elt_size +
-                       MALLOC_ELEM_TRAILER_LEN, ar->page_sz);
+                       MALLOC_ELEM_OVERHEAD, ar->page_sz);
        n_segs = alloc_sz / ar->page_sz;
 
        /* we can't know in advance how many pages we'll need, so we malloc */