[1/4] eal: fix list index for 256 byte element

Message ID 20230519042923.314670-2-ruifeng.wang@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Heap library and test case changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ruifeng Wang May 19, 2023, 4:29 a.m. UTC
  Elements with 2^8B size should fall into index 1 of the list.

Fixes: f62f4a375ff4 ("malloc: optimize 4K allocations")
Cc: changfengnan@bytedance.com
Cc: stable@dpdk.org

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/eal/common/malloc_elem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Burakov, Anatoly May 19, 2023, 11:10 a.m. UTC | #1
On 5/19/2023 5:29 AM, Ruifeng Wang wrote:
> Elements with 2^8B size should fall into index 1 of the list.
> 
> Fixes: f62f4a375ff4 ("malloc: optimize 4K allocations")
> Cc: changfengnan@bytedance.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  

Patch

diff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c
index 35a2313d04..619c040aa3 100644
--- a/lib/eal/common/malloc_elem.c
+++ b/lib/eal/common/malloc_elem.c
@@ -382,7 +382,7 @@  malloc_elem_free_list_index(size_t size)
 	size_t log2;
 	size_t index;
 
-	if (size <= (1UL << MALLOC_MINSIZE_LOG2))
+	if (size < (1UL << MALLOC_MINSIZE_LOG2))
 		return 0;
 
 	/* Find next power of 2 > size. */