DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal: fixes the bug where rte_malloc() fails to allocates memory
@ 2022-05-25  5:18 Fidaullah Noonari
  2022-06-16  7:53 ` David Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fidaullah Noonari @ 2022-05-25  5:18 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev, Fidaullah Noonari

if rte malloc is called to allocate memory of size
is between multiple of hugepage size minus malloc_header_len
and hugepage size rte_malloc fails to allocate memory.
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

Signed-off-by: Fidaullah Noonari <fidaullah.noonari@emumba.com>
---
 lib/eal/common/malloc_heap.c | 2 +-
 lib/eal/common/malloc_mp.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index a3d26fcbea..27a52266ad 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -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 */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 207b90847e..2b8eb51067 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -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 */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-05  5:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25  5:18 [PATCH] eal: fixes the bug where rte_malloc() fails to allocates memory Fidaullah Noonari
2022-06-16  7:53 ` David Marchand
2022-06-18 11:29 ` Dmitry Kozlyuk
2022-06-22 17:03   ` David Marchand
2022-06-22 21:18     ` Dmitry Kozlyuk
2022-07-05  5:04   ` Fidaullah Noonari
2022-06-23  7:50 ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).