<div dir="ltr"><div dir="ltr"><div>Hi Fidaullah,</div><div><br></div><div>Thanks for the fix,<br></div><div>Acked-by: Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com">dmitry.kozliuk@gmail.com</a>></div><div><br></div><div><br></div><div>Anatoly, I noticed a couple of other things while testing this.<br></div><div><br></div><div>1. Consider:</div><div><br></div><div>elt_size = pg_sz - MALLOC_ELEM_OVERHEAD</div><div>rte_malloc(align=0) which is converted to align = 1.</div><div><br></div><div>Obviously, such an element fits into one page, however:<br></div><div><br></div><div>alloc_sz = RTE_ALIGN_CEIL(1 + pg_sz +</div><div>                (MALLOC_ELEM_OVERHEAD - MALLOC_ELEM_OVERHEAD),</div><div>                pg_sz) == 2 * pg_sz.</div><div><br></div><div>This can unnecessarily hit an allocation limit from the system or EAL.<br></div><div>I suggest, in both places:<br></div><div><br> </div><div>alloc_sz = RTE_ALIGN_CEIL(RTE_ALIGN_CEIL(elt_size, align) +<br>                                     MALLOC_ELEM_OVERHEAD, pg_sz);</div><div><br></div><div>This would be symmetric with malloc_elem_can_hold().<br></div><div><br></div><div>2. Alignment calculation depends on whether we allocated new pages or not:<br></div><div><br></div><div>malloc_heap_alloc_on_heap_id(align = 0) -></div><div>heap_alloc(align = 1) -></div><div>find_suitable_element(align = RTE_CACHE_LINE_ROUNDUP(align))<br><br>malloc_heap_alloc_on_heap_id(align = 0) -><br>alloc_more_mem_on_socket(align = 1) -><br>try_expand_heap() -> ... -><br>alloc_pages_on_heap(align = 1) -><br>find_suitable_element(align = 1)<span style="color:rgb(220,220,170)"></span></div><div><br></div></div><div>Why do we call find_suitable_element() directly and not just return</div><div>and repeat the heap_alloc() attempt?</div></div>