All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Heap library and test case changes
@ 2023-05-19  4:29 Ruifeng Wang
  2023-05-19  4:29 ` [PATCH 1/4] eal: fix list index for 256 byte element Ruifeng Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Ruifeng Wang @ 2023-05-19  4:29 UTC (permalink / raw)
  Cc: dev, anatoly.burakov, honnappa.nagarahalli, feifei.wang2, nd,
	Ruifeng Wang

This series fixed a heap free list management issue which was captured
by unit test failure.
It also includes fixes of the unit test.

Ruifeng Wang (4):
  eal: fix list index for 256 byte element
  eal: simplify check condition
  test/malloc: fix missing free
  test/malloc: fix case expectation

 app/test/test_malloc.c       | 21 +++++++++++----------
 lib/eal/common/malloc_elem.c |  2 +-
 lib/eal/common/malloc_heap.c |  2 +-
 3 files changed, 13 insertions(+), 12 deletions(-)

-- 
2.25.1


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

* [PATCH 1/4] eal: fix list index for 256 byte element
  2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
@ 2023-05-19  4:29 ` Ruifeng Wang
  2023-05-19 11:10   ` Burakov, Anatoly
  2023-05-19  4:29 ` [PATCH 2/4] eal: simplify check condition Ruifeng Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Ruifeng Wang @ 2023-05-19  4:29 UTC (permalink / raw)
  To: Anatoly Burakov, Fengnan Chang, Morten Brørup
  Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, Ruifeng Wang, stable

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(-)

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. */
-- 
2.25.1


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

* [PATCH 2/4] eal: simplify check condition
  2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
  2023-05-19  4:29 ` [PATCH 1/4] eal: fix list index for 256 byte element Ruifeng Wang
@ 2023-05-19  4:29 ` Ruifeng Wang
  2023-05-19 11:06   ` Burakov, Anatoly
  2023-05-19  4:29 ` [PATCH 3/4] test/malloc: fix missing free Ruifeng Wang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Ruifeng Wang @ 2023-05-19  4:29 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, Ruifeng Wang

The alt_elem is initialized to null. Checking only size hint flag is
sufficient to return a proper value.
Removed the redundant check.

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

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index d25bdc98f9..fa709ac567 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -168,7 +168,7 @@ find_suitable_element(struct malloc_heap *heap, size_t size,
 		}
 	}
 
-	if ((alt_elem != NULL) && (flags & RTE_MEMZONE_SIZE_HINT_ONLY))
+	if (flags & RTE_MEMZONE_SIZE_HINT_ONLY)
 		return alt_elem;
 
 	return NULL;
-- 
2.25.1


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

* [PATCH 3/4] test/malloc: fix missing free
  2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
  2023-05-19  4:29 ` [PATCH 1/4] eal: fix list index for 256 byte element Ruifeng Wang
  2023-05-19  4:29 ` [PATCH 2/4] eal: simplify check condition Ruifeng Wang
@ 2023-05-19  4:29 ` Ruifeng Wang
  2023-05-19 11:08   ` Burakov, Anatoly
  2023-05-19  4:29 ` [PATCH 4/4] test/malloc: fix case expectation Ruifeng Wang
  2023-06-05 16:06 ` [PATCH 0/4] Heap library and test case changes Thomas Monjalon
  4 siblings, 1 reply; 10+ messages in thread
From: Ruifeng Wang @ 2023-05-19  4:29 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, Ruifeng Wang, stable

Free the allocated buffer before returning.

Fixes: a40a1f8231b4 ("app: various tests update")
Cc: stable@dpdk.org

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
---
 app/test/test_malloc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index de40e50611..f144b89d88 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -937,6 +937,7 @@ test_alloc_single_socket(int32_t socket)
 	if (mem == NULL)
 		return -1;
 	if (addr_to_socket(mem) != desired_socket) {
+		rte_free(mem);
 		return -1;
 	}
 	rte_free(mem);
-- 
2.25.1


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

* [PATCH 4/4] test/malloc: fix case expectation
  2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
                   ` (2 preceding siblings ...)
  2023-05-19  4:29 ` [PATCH 3/4] test/malloc: fix missing free Ruifeng Wang
@ 2023-05-19  4:29 ` Ruifeng Wang
  2023-05-19 11:07   ` Burakov, Anatoly
  2023-06-05 16:06 ` [PATCH 0/4] Heap library and test case changes Thomas Monjalon
  4 siblings, 1 reply; 10+ messages in thread
From: Ruifeng Wang @ 2023-05-19  4:29 UTC (permalink / raw)
  To: Anatoly Burakov
  Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, Ruifeng Wang, stable

The case expects all stats to be equal. Therefor the conditions
in check should be logically or'ed.

Fixes: a40a1f8231b4 ("app: various tests update")
Cc: stable@dpdk.org

Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
---
 app/test/test_malloc.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c
index f144b89d88..ff081dd931 100644
--- a/app/test/test_malloc.c
+++ b/app/test/test_malloc.c
@@ -302,11 +302,11 @@ test_multi_alloc_statistics(void)
 	rte_malloc_get_socket_stats(socket,&post_stats);
 	/* Check statistics reported are correct */
 	/* All post stats should be equal to pre stats after alloc freed */
-	if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
-			(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
-			(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
-			(post_stats.alloc_count!=pre_stats.alloc_count)&&
-			(post_stats.free_count!=pre_stats.free_count)) {
+	if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) ||
+			(post_stats.heap_freesz_bytes != pre_stats.heap_freesz_bytes) ||
+			(post_stats.heap_allocsz_bytes != pre_stats.heap_allocsz_bytes) ||
+			(post_stats.alloc_count != pre_stats.alloc_count) ||
+			(post_stats.free_count != pre_stats.free_count)) {
 		printf("Malloc statistics are incorrect - freed alloc\n");
 		return -1;
 	}
@@ -363,11 +363,11 @@ test_multi_alloc_statistics(void)
 		return -1;
 	}
 
-	if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) &&
-			(post_stats.heap_freesz_bytes!=pre_stats.heap_freesz_bytes) &&
-			(post_stats.heap_allocsz_bytes!=pre_stats.heap_allocsz_bytes)&&
-			(post_stats.alloc_count!=pre_stats.alloc_count)&&
-			(post_stats.free_count!=pre_stats.free_count)) {
+	if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) ||
+			(post_stats.heap_freesz_bytes != pre_stats.heap_freesz_bytes) ||
+			(post_stats.heap_allocsz_bytes != pre_stats.heap_allocsz_bytes) ||
+			(post_stats.alloc_count != pre_stats.alloc_count) ||
+			(post_stats.free_count != pre_stats.free_count)) {
 		printf("Malloc statistics are incorrect - freed alloc\n");
 		return -1;
 	}
-- 
2.25.1


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

* Re: [PATCH 2/4] eal: simplify check condition
  2023-05-19  4:29 ` [PATCH 2/4] eal: simplify check condition Ruifeng Wang
@ 2023-05-19 11:06   ` Burakov, Anatoly
  0 siblings, 0 replies; 10+ messages in thread
From: Burakov, Anatoly @ 2023-05-19 11:06 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, honnappa.nagarahalli, feifei.wang2, nd

On 5/19/2023 5:29 AM, Ruifeng Wang wrote:
> The alt_elem is initialized to null. Checking only size hint flag is
> sufficient to return a proper value.
> Removed the redundant check.
> 
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly


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

* Re: [PATCH 4/4] test/malloc: fix case expectation
  2023-05-19  4:29 ` [PATCH 4/4] test/malloc: fix case expectation Ruifeng Wang
@ 2023-05-19 11:07   ` Burakov, Anatoly
  0 siblings, 0 replies; 10+ messages in thread
From: Burakov, Anatoly @ 2023-05-19 11:07 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, stable

On 5/19/2023 5:29 AM, Ruifeng Wang wrote:
> The case expects all stats to be equal. Therefor the conditions
> in check should be logically or'ed.
> 
> Fixes: a40a1f8231b4 ("app: various tests update")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> ---

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

-- 
Thanks,
Anatoly


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

* Re: [PATCH 3/4] test/malloc: fix missing free
  2023-05-19  4:29 ` [PATCH 3/4] test/malloc: fix missing free Ruifeng Wang
@ 2023-05-19 11:08   ` Burakov, Anatoly
  0 siblings, 0 replies; 10+ messages in thread
From: Burakov, Anatoly @ 2023-05-19 11:08 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, stable

On 5/19/2023 5:29 AM, Ruifeng Wang wrote:
> Free the allocated buffer before returning.
> 
> Fixes: a40a1f8231b4 ("app: various tests update")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Feifei Wang <feifei.wang2@arm.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly


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

* Re: [PATCH 1/4] eal: fix list index for 256 byte element
  2023-05-19  4:29 ` [PATCH 1/4] eal: fix list index for 256 byte element Ruifeng Wang
@ 2023-05-19 11:10   ` Burakov, Anatoly
  0 siblings, 0 replies; 10+ messages in thread
From: Burakov, Anatoly @ 2023-05-19 11:10 UTC (permalink / raw)
  To: Ruifeng Wang, Fengnan Chang, Morten Brørup
  Cc: dev, honnappa.nagarahalli, feifei.wang2, nd, stable

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>

-- 
Thanks,
Anatoly


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

* Re: [PATCH 0/4] Heap library and test case changes
  2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
                   ` (3 preceding siblings ...)
  2023-05-19  4:29 ` [PATCH 4/4] test/malloc: fix case expectation Ruifeng Wang
@ 2023-06-05 16:06 ` Thomas Monjalon
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Monjalon @ 2023-06-05 16:06 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, anatoly.burakov, honnappa.nagarahalli, feifei.wang2, nd

19/05/2023 06:29, Ruifeng Wang:
> This series fixed a heap free list management issue which was captured
> by unit test failure.
> It also includes fixes of the unit test.
> 
> Ruifeng Wang (4):
>   eal: fix list index for 256 byte element
>   eal: simplify check condition
>   test/malloc: fix missing free
>   test/malloc: fix case expectation

Applied, thanks.




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

end of thread, other threads:[~2023-06-05 16:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19  4:29 [PATCH 0/4] Heap library and test case changes Ruifeng Wang
2023-05-19  4:29 ` [PATCH 1/4] eal: fix list index for 256 byte element Ruifeng Wang
2023-05-19 11:10   ` Burakov, Anatoly
2023-05-19  4:29 ` [PATCH 2/4] eal: simplify check condition Ruifeng Wang
2023-05-19 11:06   ` Burakov, Anatoly
2023-05-19  4:29 ` [PATCH 3/4] test/malloc: fix missing free Ruifeng Wang
2023-05-19 11:08   ` Burakov, Anatoly
2023-05-19  4:29 ` [PATCH 4/4] test/malloc: fix case expectation Ruifeng Wang
2023-05-19 11:07   ` Burakov, Anatoly
2023-06-05 16:06 ` [PATCH 0/4] Heap library and test case changes Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.