From patchwork Fri May 19 04:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 127068 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BEB0242B43; Fri, 19 May 2023 06:30:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B17A642B8B; Fri, 19 May 2023 06:30:14 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id D269E406B5; Fri, 19 May 2023 06:30:13 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2EA1A1FB; Thu, 18 May 2023 21:30:58 -0700 (PDT) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 73D433F762; Thu, 18 May 2023 21:30:10 -0700 (PDT) From: Ruifeng Wang To: Anatoly Burakov , Fengnan Chang , =?utf-8?q?Morten_Br=C3=B8rup?= Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, feifei.wang2@arm.com, nd@arm.com, Ruifeng Wang , stable@dpdk.org Subject: [PATCH 1/4] eal: fix list index for 256 byte element Date: Fri, 19 May 2023 12:29:20 +0800 Message-Id: <20230519042923.314670-2-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519042923.314670-1-ruifeng.wang@arm.com> References: <20230519042923.314670-1-ruifeng.wang@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Anatoly Burakov --- 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. */ From patchwork Fri May 19 04:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 127069 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15B6742B43; Fri, 19 May 2023 06:30:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0868D42D36; Fri, 19 May 2023 06:30:22 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 49D1742D32 for ; Fri, 19 May 2023 06:30:20 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AA8212F4; Thu, 18 May 2023 21:31:04 -0700 (PDT) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B7F443F762; Thu, 18 May 2023 21:30:17 -0700 (PDT) From: Ruifeng Wang To: Anatoly Burakov Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, feifei.wang2@arm.com, nd@arm.com, Ruifeng Wang Subject: [PATCH 2/4] eal: simplify check condition Date: Fri, 19 May 2023 12:29:21 +0800 Message-Id: <20230519042923.314670-3-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519042923.314670-1-ruifeng.wang@arm.com> References: <20230519042923.314670-1-ruifeng.wang@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: Feifei Wang Acked-by: Anatoly Burakov --- 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; From patchwork Fri May 19 04:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 127070 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A98D42B43; Fri, 19 May 2023 06:30:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DFC342D3A; Fri, 19 May 2023 06:30:32 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 93BF342D32; Fri, 19 May 2023 06:30:30 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE0D21FB; Thu, 18 May 2023 21:31:14 -0700 (PDT) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BCA223F762; Thu, 18 May 2023 21:30:27 -0700 (PDT) From: Ruifeng Wang To: Anatoly Burakov Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, feifei.wang2@arm.com, nd@arm.com, Ruifeng Wang , stable@dpdk.org Subject: [PATCH 3/4] test/malloc: fix missing free Date: Fri, 19 May 2023 12:29:22 +0800 Message-Id: <20230519042923.314670-4-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519042923.314670-1-ruifeng.wang@arm.com> References: <20230519042923.314670-1-ruifeng.wang@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Free the allocated buffer before returning. Fixes: a40a1f8231b4 ("app: various tests update") Cc: stable@dpdk.org Signed-off-by: Ruifeng Wang Reviewed-by: Feifei Wang Acked-by: Anatoly Burakov --- 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); From patchwork Fri May 19 04:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruifeng Wang X-Patchwork-Id: 127071 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E8E942B43; Fri, 19 May 2023 06:30:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1C95242D32; Fri, 19 May 2023 06:30:40 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 70DE54161A; Fri, 19 May 2023 06:30:38 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2C341FB; Thu, 18 May 2023 21:31:22 -0700 (PDT) Received: from net-arm-n1amp-02.shanghai.arm.com (net-arm-n1amp-02.shanghai.arm.com [10.169.210.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AACA93F762; Thu, 18 May 2023 21:30:35 -0700 (PDT) From: Ruifeng Wang To: Anatoly Burakov Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, feifei.wang2@arm.com, nd@arm.com, Ruifeng Wang , stable@dpdk.org Subject: [PATCH 4/4] test/malloc: fix case expectation Date: Fri, 19 May 2023 12:29:23 +0800 Message-Id: <20230519042923.314670-5-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519042923.314670-1-ruifeng.wang@arm.com> References: <20230519042923.314670-1-ruifeng.wang@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: Feifei Wang Acked-by: Anatoly Burakov --- 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; }