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 2A9FF45E41 for ; Sat, 7 Dec 2024 09:08:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 231E140E4C; Sat, 7 Dec 2024 09:08:16 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by mails.dpdk.org (Postfix) with ESMTP id 3976440E7C for ; Sat, 7 Dec 2024 09:08:15 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZY5VUGZvce/AMlMlexWjEGAwxGYuSztj5wMLxa2q5CAxABcckmaL0nQvQuA6LlYTG8ZIXNkQWHCYSBzBTxS7gZo5w38e1ptdhOfAYd+lsTO5y/Hf2CzQVWcjn+s0t1ObwbcYYH4vH/FiYqp5nEIYAaFig7GECXMjSXIKgUZEpWm3ddDbB/cG2aiRg27aZsFsplIW8f2vAWpd005C+gLJ+OtKPGj1eOCPlrI48fWKgP0DXq4kJJS/1894R5gDE7Gc44uB7JWwdl6OJrs0Nfzc5g2YSmcCa/Llg4OBWB4XomflcBGMKDj4nDe2CFEB+cUdwBiF6++bF0OcTYAKxxnsaw== 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=2+7LMKvGt5aDkHlwg90ZroYspS6wBGH7FsCC4XQzhUY=; b=BGknHzsFoIVuUL5mV7KtHrRkL88pYUASjU0B/s3QvGnhhsHhvHBecKlNYUNsZ+J9ntuHi3zd3T1ZJfi7lEGTUFO/va5hd/ZZ7JMuR6gxkePlikAUOy7Ehe9vA/NEopX0TsdrUcx+AFCG5OriNQTBeEr1BG/J+qDs3eg5qDJs0jAAF6ust8DNGRKv91siQKFDZSYsglVyKepz118UmXu6cIDvqPSK6wm0EjbGd2aEO3sIff9eW4YIsWDbaLw9fpPLXUkLSjHU04kyqflu0AdFboVuva1M5k/eLS5fCoLAvc8NAWC3j2nRZwuFHsjAdvYlnvicjPZ1CDjlsieJSFBNOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org 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=2+7LMKvGt5aDkHlwg90ZroYspS6wBGH7FsCC4XQzhUY=; b=M4DeDUONfgx4PYLbAF7z9AA/eTMcududjqjzUksR7uQ2Erlb3bzJR1X3QB4ZEQQ44w+VWTnJtm9gYa97SP2s2CCADY6UDRQhesqNXX+NW3r7qiJdijKdXlxFHkiRCI4YXezvtsN+Np/xd1TkAtWbxnEvnKFCq+Ib6sUqsqS+iA7LlABieivdI6lbg2Jd0Sl86bFHPleO/SYbomy0yBxA1TK/6NPB69wXrufrNqCne3SGlR7XqfBioAiqXYGs96n5rrSTbGqybhtJir7KG/U4Uc7MhcTvz/xmj+REBnaYhkjZUbe9Dgx5pYHczkMYW8knvY47kFJNZlewecwHLWiEyg== Received: from BN0PR04CA0073.namprd04.prod.outlook.com (2603:10b6:408:ea::18) by LV3PR12MB9094.namprd12.prod.outlook.com (2603:10b6:408:19e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sat, 7 Dec 2024 08:08:07 +0000 Received: from BL02EPF00021F6D.namprd02.prod.outlook.com (2603:10b6:408:ea:cafe::99) by BN0PR04CA0073.outlook.office365.com (2603:10b6:408:ea::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Sat, 7 Dec 2024 08:08:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF00021F6D.mail.protection.outlook.com (10.167.249.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Sat, 7 Dec 2024 08:08:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Dec 2024 00:07:55 -0800 Received: from nvidia.com (10.126.231.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.4; Sat, 7 Dec 2024 00:07:54 -0800 From: Xueming Li To: Shani Peretz CC: Xueming Li , Bing Zhao , "dpdk stable" Subject: patch 'common/mlx5: fix misalignment' has been queued to stable release 23.11.3 Date: Sat, 7 Dec 2024 16:00:30 +0800 Message-ID: <20241207080055.488538-73-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241207080055.488538-1-xuemingl@nvidia.com> References: <20241111062847.216344-122-xuemingl@nvidia.com> <20241207080055.488538-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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: BL02EPF00021F6D:EE_|LV3PR12MB9094:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f8d7b31-6049-4fc6-3ca3-08dd169648c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?whmOO+pfbETN4rw0YDek15/IKzupwA6rpVWrLBLh9vZ6xDObvr1k9LqD5AaY?= =?us-ascii?Q?UHQrjnMTTOKyuyMIstzOzY3CRwshjppAWxDha3cOPHCBy0usYFBOrmRWi1oo?= =?us-ascii?Q?Fmap+X/dAhWgU/8FYeQc7m7t2OYGL/JlkypwrViW1N5ZnvRsSB4kvl4pf9hK?= =?us-ascii?Q?qt9RMq71BE3v/UknhkZwfC3GH3WjucKIh5N4y5hRkZI5QyjxhGdGG23ECwFK?= =?us-ascii?Q?xooUdRB0X46rVnBobBEK2lJVT2jnjmceFrDjIPKfWgBRW8A+2Fsn4ORca4fq?= =?us-ascii?Q?fpQ2MrxMa5+/RBEQD9cXpfC2CSroc8wGLTiwh4rt9ngEYFkci3pP7lI9dFLy?= =?us-ascii?Q?6c7EcWQ+3Z6nBQA9r8G1fusSuHXmsouGSFACIejwaHC6nWf99mN4CML0gIDE?= =?us-ascii?Q?U8I2WCeQsECTzgfk6U+Voe5nNX1bcNf6rZaJGWcnTdSUpXOa7CRdzEuBRxNo?= =?us-ascii?Q?2+tjepmZ+qX2NKYwDcX8vZnr1kAvGWqm29k1SlOXgY7tDCi/T8vMmHlkJXoW?= =?us-ascii?Q?bvnS+OPp9hPkbPOviMqjdzxkEnOtxr1WRE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WakY6fA5zn93RQMuAcViOFqf6?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2024 08:08:07.6238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f8d7b31-6049-4fc6-3ca3-08dd169648c5 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9094 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.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 12/10/24. 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=83af285731ae630e8db81a4d5a3d2e93f6826726 Thanks. Xueming Li --- >From 83af285731ae630e8db81a4d5a3d2e93f6826726 Mon Sep 17 00:00:00 2001 From: Shani Peretz Date: Tue, 12 Nov 2024 10:21:26 +0200 Subject: [PATCH] common/mlx5: fix misalignment Cc: Xueming Li [ upstream commit 90967539d0d1afcfd5237ed85efdc430359a0e6b ] ASan reported a runtime error due to misalignment involving three structures. The first issue arises when accessing l_inconst->cache[MLX5_LIST_GLOBAL]->h. If struct mlx5_list_cache is not properly aligned, the pointer gc, assigned to l_inconst->cache[MLX5_LIST_GLOBAL], could be misaligned. To address this, the __rte_aligned(16) attribute was added to struct mlx5_list_inconst in struct mlx5_list, which includes struct mlx5_list_cache, ensuring that the entire mlx5_list structure, including mlx5_list_cache, is aligned to 64 bytes. To resolve misalignment issues with struct mlx5_flow_handle, The initialization of resources for the ipool ensures that the ipool size is rounded up to the 8-byte boundary The error in assigning values to actions[i] was due to potential padding or misalignment in struct mlx5_modification_cmd. To prevent such issues, the __rte_packed attribute was added to struct mlx5_modification_cmd, ensuring that the structure is packed without extra padding which helps avoid misaligned memory accesses. Two performance degradation tests were conducted. Following are the results comparing this commit to the most recent commit in mlnx_dpdk_22.11 at that time (b69408ae453). Before asan misalignment fix (average kflows/sec) - Insertion - 4461.269, Deletion - 7799.9992 After: Insertion - 4579.0642 , Deletion - 7913.0034 Fixes: 9a4c36880704 ("common/mlx5: optimize cache list object memory") Signed-off-by: Shani Peretz Acked-by: Bing Zhao --- drivers/common/mlx5/mlx5_common_utils.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 4 ++-- drivers/net/mlx5/mlx5.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common_utils.h b/drivers/common/mlx5/mlx5_common_utils.h index ae15119a33..6db0105c53 100644 --- a/drivers/common/mlx5/mlx5_common_utils.h +++ b/drivers/common/mlx5/mlx5_common_utils.h @@ -131,7 +131,7 @@ struct mlx5_list_inconst { * For huge amount of entries, please consider hash list. * */ -struct mlx5_list { +struct __rte_aligned(16) mlx5_list { struct mlx5_list_const l_const; struct mlx5_list_inconst l_inconst; }; diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 0875256e36..79533ff35a 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -923,7 +923,7 @@ struct mlx5_modification_cmd { unsigned int field:12; unsigned int action_type:4; }; - }; + } __rte_packed; union { uint32_t data1; uint8_t data[4]; @@ -934,7 +934,7 @@ struct mlx5_modification_cmd { unsigned int dst_field:12; unsigned int rsvd4:4; }; - }; + } __rte_packed; }; typedef uint64_t u64; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 25182bce39..584a51b393 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -906,7 +906,7 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh) */ case MLX5_IPOOL_MLX5_FLOW: cfg.size = sh->config.dv_flow_en ? - sizeof(struct mlx5_flow_handle) : + RTE_ALIGN_MUL_CEIL(sizeof(struct mlx5_flow_handle), 8) : MLX5_FLOW_HANDLE_VERBS_SIZE; break; #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-12-06 23:26:46.500897901 +0800 +++ 0072-common-mlx5-fix-misalignment.patch 2024-12-06 23:26:44.043044827 +0800 @@ -1 +1 @@ -From 90967539d0d1afcfd5237ed85efdc430359a0e6b Mon Sep 17 00:00:00 2001 +From 83af285731ae630e8db81a4d5a3d2e93f6826726 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 90967539d0d1afcfd5237ed85efdc430359a0e6b ] @@ -38 +40,0 @@ -Cc: stable@dpdk.org @@ -49 +51 @@ -index c5eff7a0bf..9139bc6829 100644 +index ae15119a33..6db0105c53 100644 @@ -62 +64 @@ -index 210158350d..2d82807bc2 100644 +index 0875256e36..79533ff35a 100644 @@ -65 +67 @@ -@@ -941,7 +941,7 @@ struct mlx5_modification_cmd { +@@ -923,7 +923,7 @@ struct mlx5_modification_cmd { @@ -74 +76 @@ -@@ -952,7 +952,7 @@ struct mlx5_modification_cmd { +@@ -934,7 +934,7 @@ struct mlx5_modification_cmd { @@ -84 +86 @@ -index 52b90e6ff3..6e4473e2f4 100644 +index 25182bce39..584a51b393 100644 @@ -87 +89 @@ -@@ -907,7 +907,7 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh) +@@ -906,7 +906,7 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh)