From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59FD346BAE for ; Fri, 18 Jul 2025 21:35:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54A3840611; Fri, 18 Jul 2025 21:35:17 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id E0B4440E30 for ; Fri, 18 Jul 2025 21:35:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752867315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vsDLZi430JfCkmSHGzQplFUCYMk5O/vBvQgxuIssEdA=; b=e5gPINXEhzche/THnqYXo6QmOFD057M+fSV2WkQDQ0hWyeUelm8NHmbfU6J3FH18XWZfuo mKRAdlTp7V9f7k7FLhWJB8rRrF06PFN9k4bDjcr87HJ89JvYF9lZQG1XqblEx61aCqW9pO C8YNxd+USKkcrmZqjJneQTGohOH942Y= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-MDFUCihSMnKXy5oym0JKGQ-1; Fri, 18 Jul 2025 15:35:13 -0400 X-MC-Unique: MDFUCihSMnKXy5oym0JKGQ-1 X-Mimecast-MFC-AGG-ID: MDFUCihSMnKXy5oym0JKGQ_1752867313 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 03A6419560B6; Fri, 18 Jul 2025 19:35:13 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.40]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C1D718003FC; Fri, 18 Jul 2025 19:35:11 +0000 (UTC) From: Kevin Traynor To: Bruce Richardson Cc: Chengwen Feng , dpdk stable Subject: patch 'test/malloc: improve resiliency' has been queued to stable release 24.11.3 Date: Fri, 18 Jul 2025 20:30:00 +0100 Message-ID: <20250718193247.1008129-66-ktraynor@redhat.com> In-Reply-To: <20250718193247.1008129-1-ktraynor@redhat.com> References: <20250718193247.1008129-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LLTJhabHZ24nmSOqrM1KVu201khKqrlxrZ-hAVEO0Tk_1752867313 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 24.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/23/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/935bcec6d4bc380929e209d06baac9d7e3df61e4 Thanks. Kevin --- >From 935bcec6d4bc380929e209d06baac9d7e3df61e4 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Wed, 26 Mar 2025 17:13:24 +0000 Subject: [PATCH] test/malloc: improve resiliency [ upstream commit 7777215715d475b5e884179de39ff4bc6b8cbf72 ] The test case "test_multi_alloc_statistics" was brittle in that it did some allocations and frees and then checked statistics without considering the initial state of the malloc heaps. This meant that, depending on what allocations/frees were done beforehand, the test can sometimes fail. We can improve resiliency by running the test using a new malloc heap, which means it is unaffected by any previous allocations. Bugzilla ID: 1579 Fixes: a40a1f8231b4 ("app: various tests update") Signed-off-by: Bruce Richardson Acked-by: Chengwen Feng --- app/test/test_malloc.c | 77 +++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c index 02a7d8ef20..d6f8da3b24 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -26,4 +26,5 @@ #include #include +#include #include @@ -268,4 +269,5 @@ static int test_multi_alloc_statistics(void) { + int ret = -1; /* default return is error, cleared at end on success */ int socket = 0; struct rte_malloc_socket_stats pre_stats, post_stats ,first_stats, second_stats; @@ -273,4 +275,40 @@ test_multi_alloc_statistics(void) int align = 1024; int overhead = 0; + const size_t pgsz = rte_mem_page_size(); + const size_t heap_size = (1 << 22); + + if (pgsz > heap_size) { + printf("Page size (%zu) is bigger than heap size, skipping alloc stats test\n", + pgsz); + return TEST_SKIPPED; + } + if (heap_size % pgsz != 0) { + printf("Heap size (%zu) is not a multiple of page size (%zu), skipping alloc stats test\n", + heap_size, pgsz); + return TEST_SKIPPED; + } + + if (rte_malloc_heap_create(__func__) != 0) { + printf("Failed to create test malloc heap\n"); + goto end; + } + + /* Allocate some memory using malloc and add it to our test heap. */ + void *unaligned_memory = malloc(heap_size + pgsz); + if (unaligned_memory == NULL) { + printf("Failed to allocate memory\n"); + goto cleanup_empty_heap; + } + void *memory = RTE_PTR_ALIGN(unaligned_memory, pgsz); + if (rte_malloc_heap_memory_add(__func__, memory, heap_size, NULL, + heap_size / pgsz, pgsz) != 0) { + printf("Failed to add memory to heap\n"); + goto cleanup_allocated_memory; + } + socket = rte_malloc_heap_get_socket(__func__); + if (socket < 0) { + printf("Failed to get socket for test malloc heap.\n"); + goto cleanup_all; + } /* Dynamically calculate the overhead by allocating one cacheline and @@ -281,5 +319,5 @@ test_multi_alloc_statistics(void) void *dummy = rte_malloc_socket(NULL, RTE_CACHE_LINE_SIZE, 0, socket); if (dummy == NULL) - return -1; + goto cleanup_all; rte_malloc_get_socket_stats(socket, &post_stats); @@ -296,5 +334,6 @@ test_multi_alloc_statistics(void) void *p1 = rte_malloc_socket("stats", size , align, socket); if (!p1) - return -1; + goto cleanup_all; + rte_free(p1); rte_malloc_dump_stats(stdout, "stats"); @@ -309,5 +348,5 @@ test_multi_alloc_statistics(void) (post_stats.free_count != pre_stats.free_count)) { printf("Malloc statistics are incorrect - freed alloc\n"); - return -1; + goto cleanup_all; } /* Check two consecutive allocations */ @@ -317,10 +356,10 @@ test_multi_alloc_statistics(void) void *p2 = rte_malloc_socket("add", size ,align, socket); if (!p2) - return -1; + goto cleanup_all; rte_malloc_get_socket_stats(socket,&first_stats); void *p3 = rte_malloc_socket("add2", size,align, socket); if (!p3) - return -1; + goto cleanup_all; rte_malloc_get_socket_stats(socket,&second_stats); @@ -334,5 +373,5 @@ test_multi_alloc_statistics(void) if(second_stats.heap_totalsz_bytes != first_stats.heap_totalsz_bytes) { printf("Incorrect heap statistics: Total size \n"); - return -1; + goto cleanup_all; } /* Check allocated size is equal to two additions plus overhead */ @@ -340,15 +379,15 @@ test_multi_alloc_statistics(void) size + overhead + first_stats.heap_allocsz_bytes) { printf("Incorrect heap statistics: Allocated size \n"); - return -1; + goto cleanup_all; } /* Check that allocation count increments correctly i.e. +1 */ if (second_stats.alloc_count != first_stats.alloc_count + 1) { printf("Incorrect heap statistics: Allocated count \n"); - return -1; + goto cleanup_all; } if (second_stats.free_count != first_stats.free_count){ printf("Incorrect heap statistics: Free count \n"); - return -1; + goto cleanup_all; } @@ -356,10 +395,10 @@ test_multi_alloc_statistics(void) if (post_stats.greatest_free_size != pre_stats.greatest_free_size) { printf("Incorrect heap statistics: Greatest free size \n"); - return -1; + goto cleanup_all; } /* Free size must equal the original free size minus the new allocation*/ if (first_stats.heap_freesz_bytes <= second_stats.heap_freesz_bytes) { printf("Incorrect heap statistics: Free size \n"); - return -1; + goto cleanup_all; } @@ -370,7 +409,19 @@ test_multi_alloc_statistics(void) (post_stats.free_count != pre_stats.free_count)) { printf("Malloc statistics are incorrect - freed alloc\n"); - return -1; + goto cleanup_all; } - return 0; + + /* set return value as success before cleanup */ + ret = 0; + + /* cleanup */ +cleanup_all: + rte_malloc_heap_memory_remove(__func__, memory, heap_size); +cleanup_allocated_memory: + free(unaligned_memory); +cleanup_empty_heap: + rte_malloc_heap_destroy(__func__); +end: + return ret; } -- 2.50.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-07-18 20:29:13.350744772 +0100 +++ 0066-test-malloc-improve-resiliency.patch 2025-07-18 20:29:10.966907441 +0100 @@ -1 +1 @@ -From 7777215715d475b5e884179de39ff4bc6b8cbf72 Mon Sep 17 00:00:00 2001 +From 935bcec6d4bc380929e209d06baac9d7e3df61e4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 7777215715d475b5e884179de39ff4bc6b8cbf72 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org