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 9918F46A63 for ; Thu, 26 Jun 2025 14:07:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F20A402D9; Thu, 26 Jun 2025 14:07:23 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2067.outbound.protection.outlook.com [40.107.101.67]) by mails.dpdk.org (Postfix) with ESMTP id A2A30400D6 for ; Thu, 26 Jun 2025 14:07:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p6xVv622j1D7bMdkKX0FJu52Fr6bJYXiFd4cTulmS09YxUeTIRdHoN61TdMqSnQyFJ4TQGop0Sdkchtru6p5vLzszNJkm4dmU55w+iiiZZ9uZ87b+24OJrylreWb0zQ94hIUNKrNR8Pgcn0+1wXxMgFipvcZYmvgs9eL6JZaox2RKUjXz5HYEtWl04eHCm3Y+5f/HdK/gzjEjC2KpBlvDqIqmBbFZ3zK834wyAp/FBUnJlUJFYRjgc9DYEym6BSSFGgJzviM0At8ugjTVwmG91tSWUiZ+eAih+hS+XCKpHo/KjVN75CyXGrCGLoPWRApHb7wHOApheYK0kBT3FGkTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M07waPvN4iR02Z9GehF+vlsiE1TAog/sdHIpr+YLBt0=; b=OHn0rNHNoxC/Gw9OOxFcdsls/A8+zXRNQV6szzBx81JKkgQ8GtTmdyyiBFs10STJj2GejZh0S4rhFTzVFQSOUBNHxaC8KsCcWUOKR0JbgegqXiH11vt+FZHtXaF+DLnhdjbG3aQcqmYYWE9xM41J6K9nPvCfZV7GIm69G6m2Ek/V6Le5I8oSlkB+TXAjjA+u3LgArwq+yC1mIpQnws6zldR32WBmECBdc9IDls2D7Q79HwmxE1jl/RBF9zhDcp3RRTgCshQkV2GcKxNTaneX89Vveus2bl7wIunDP4L3lF/bYwyHiCLfbB1gFlw6I5CvT3d7CtwfjYyphdb4Piilbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M07waPvN4iR02Z9GehF+vlsiE1TAog/sdHIpr+YLBt0=; b=fVK1RU/dfG7ud8ozgcWWU33A1Dr9C1u81LT7lKtgKGdhEqfVKqtwqAtRHxbAbJWOeXgydUqebK36u55IM5oOme18EhrAiRpHh0PkHNFht1Xb0JyCHrwKP/hYkUAZ7XSYTNLLCySxMQKYD38uVUET+huC87oKfwO/UCNRdIt/sKvKujfRvPBYTT54uSH3n9lrvbnRMgFWfEwr46CcBx3OD8r/trtnGbGVRBguaABVcGBmfwB37Q/UgYhJl28gCSTR8dWs8MypkfuYHpOh7ABA18Bt3eZHwHWGFEXWc6sbnsPx7t98BhJhaoNR7iX9G8y5Ql/eV16xbElZaW3SAMSj2g== Received: from BN9PR03CA0943.namprd03.prod.outlook.com (2603:10b6:408:108::18) by DS7PR12MB5792.namprd12.prod.outlook.com (2603:10b6:8:77::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.28; Thu, 26 Jun 2025 12:07:19 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::6c) by BN9PR03CA0943.outlook.office365.com (2603:10b6:408:108::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.35 via Frontend Transport; Thu, 26 Jun 2025 12:07:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.14 via Frontend Transport; Thu, 26 Jun 2025 12:07:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 26 Jun 2025 05:06:58 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Thu, 26 Jun 2025 05:06:56 -0700 From: Xueming Li To: Bruce Richardson CC: Xueming Li , Chengwen Feng , dpdk stable Subject: patch 'test/malloc: improve resiliency' has been queued to stable release 23.11.5 Date: Thu, 26 Jun 2025 20:01:16 +0800 Message-ID: <20250626120145.27369-57-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250626120145.27369-1-xuemingl@nvidia.com> References: <20250626120145.27369-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|DS7PR12MB5792:EE_ X-MS-Office365-Filtering-Correlation-Id: f4c54f85-97d4-4a7e-7752-08ddb4a9ffb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bUW3EpNU+HsX81ypSZvfkw8dozljBcZpxQAtIpUGCYJG633U9ouYMq86f4Jg?= =?us-ascii?Q?cuY+Wnr0N0KF7DsE6KH9gDUAg/OfRjhfsqBsK1LIEexQ3bKlWwn55HEVDllX?= =?us-ascii?Q?RSFe3TkkkZqU2F521COXg20ycLXfSRoMOolkst8j4bj3nAZYGfo9v5sV+ZkR?= =?us-ascii?Q?nyiZkytKwV8S/dn9f0NBkCLFfhyyZZO3SdHvi/93pt0vo/6au1KQR4KNKBnQ?= =?us-ascii?Q?BNtlnq+2weO9cXjS8Iq4vLbIsGUuhZ+Yn1YtpvQ+0H/CZrMqUDNGCaDz1Pii?= =?us-ascii?Q?zDDXCbGZl2vhTgm10IxJcG9p//Xy/u/43xCWMS3N6cOC7DVpbQVS+aigdjRi?= =?us-ascii?Q?YRTQwvsRanvt6xAg0Dp9z3i62BN6X8tckWDkx3BxPsTvgqd8bWifbRtQ1I5Y?= =?us-ascii?Q?8ysa+YeKz2Bio8N4pEh9UVw1Tk9V35zd+Lu7mqwDluQqZxEmI+170Jt2UZ++?= =?us-ascii?Q?g2D/yKhCg0F8EBKSd/9M9cuczab+VAV3quALzkb75yV/oZq15hBrbm70qslP?= =?us-ascii?Q?jkhZhE9iH0r+/3ORXE+c4v9CtK1Rx2D/v9dNO0L+2GhLO/2Yd5d+5Vm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8RDjoKDnhF/DxMKLFnM2HBRzeN5X2myJqBNoTNRZ3LmSv9QbU4es6gUEZ?= =?us-ascii?Q?6U5U6A7mZcn041DxTvRNVDnMRoN9XAXxP43QftDlOKN9+HVD2KFiIOt+6A?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2025 12:07:18.6959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4c54f85-97d4-4a7e-7752-08ddb4a9ffb3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5792 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 23.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/28/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://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=a62f48920d70c3d208363392290fd57c97200b4d Thanks. Xueming Li --- >From a62f48920d70c3d208363392290fd57c97200b4d 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 Cc: Xueming Li [ 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 cd579c503c..084c21480b 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #define N 10000 @@ -267,11 +268,48 @@ test_str_to_size(void) 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; size_t size = 2048; 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 * then comparing what was allocated from the heap. @@ -280,7 +318,7 @@ 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); @@ -295,7 +333,8 @@ 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"); @@ -308,7 +347,7 @@ test_multi_alloc_statistics(void) (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; + goto cleanup_all; } /* Check two consecutive allocations */ size = 1024; @@ -316,12 +355,12 @@ test_multi_alloc_statistics(void) rte_malloc_get_socket_stats(socket,&pre_stats); 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); @@ -333,34 +372,34 @@ 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 */ if(second_stats.heap_allocsz_bytes != 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; } /* Make sure that we didn't touch our greatest chunk: 2 * 11M) */ 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; } if ((post_stats.heap_totalsz_bytes != pre_stats.heap_totalsz_bytes) || @@ -369,9 +408,21 @@ test_multi_alloc_statistics(void) (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; + 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; } #ifdef RTE_EXEC_ENV_WINDOWS -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-06-26 19:59:19.958247337 +0800 +++ 0056-test-malloc-improve-resiliency.patch 2025-06-26 19:59:17.430418042 +0800 @@ -1 +1 @@ -From 7777215715d475b5e884179de39ff4bc6b8cbf72 Mon Sep 17 00:00:00 2001 +From a62f48920d70c3d208363392290fd57c97200b4d Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 7777215715d475b5e884179de39ff4bc6b8cbf72 ] @@ -17 +19,0 @@ -Cc: stable@dpdk.org @@ -26 +28 @@ -index 02a7d8ef20..d6f8da3b24 100644 +index cd579c503c..084c21480b 100644