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 5D32345DB9 for ; Wed, 27 Nov 2024 18:23:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55FF6402DE; Wed, 27 Nov 2024 18:23:20 +0100 (CET) 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 05489402DE for ; Wed, 27 Nov 2024 18:23:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732728198; 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=GRG3clwXgZHgKDb4nHw0UyzL56ZT7aas2vi/2NoCdCQ=; b=FqB90+UrvnKMZSVNe1hxy4Scvl/sSz5z29jL+2j8HGk8qU64sentTr1XaWpnS5/DYfdgAb 4DP02fbi2C3SCnvyHXNYq0PL+10itSOIgKNBtPOfHNUBebPOfQO30nCaiIRpxUjZ9X81e8 YViOxfvWnPrQBN79j6vSyomEPbKeGDk= Received: from mx-prod-mc-05.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-536-8E4ObW6EN3qcbzKeJpY1lQ-1; Wed, 27 Nov 2024 12:23:16 -0500 X-MC-Unique: 8E4ObW6EN3qcbzKeJpY1lQ-1 X-Mimecast-MFC-AGG-ID: 8E4ObW6EN3qcbzKeJpY1lQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D1BB41955F0A; Wed, 27 Nov 2024 17:23:15 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.52]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 81C8130001A2; Wed, 27 Nov 2024 17:23:14 +0000 (UTC) From: Kevin Traynor To: Shani Peretz Cc: Bing Zhao , dpdk stable Subject: patch 'common/mlx5: fix misalignment' has been queued to stable release 21.11.9 Date: Wed, 27 Nov 2024 17:18:56 +0000 Message-ID: <20241127171916.690404-109-ktraynor@redhat.com> In-Reply-To: <20241127171916.690404-1-ktraynor@redhat.com> References: <20241127171916.690404-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ANs-z_ZfA9tnfCeCo65Xy6KdFSQ7yIzmz1QawQX8FhA_1732728195 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 21.11.9 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/02/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/a8403f04b0d04ac2e44e4d41c3f5d114014a353f Thanks. Kevin --- >From a8403f04b0d04ac2e44e4d41c3f5d114014a353f 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 [ 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 98e487e7ef..2b013254ad 100644 --- a/drivers/common/mlx5/mlx5_common_utils.h +++ b/drivers/common/mlx5/mlx5_common_utils.h @@ -131,5 +131,5 @@ struct mlx5_list_inconst { * */ -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 58aa72df64..fd5c8b5c72 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -754,5 +754,5 @@ struct mlx5_modification_cmd { unsigned int action_type:4; }; - }; + } __rte_packed; union { uint32_t data1; @@ -765,5 +765,5 @@ struct mlx5_modification_cmd { unsigned int rsvd4:4; }; - }; + } __rte_packed; }; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index b339ccce84..20960b8b03 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -832,5 +832,5 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh, case MLX5_IPOOL_MLX5_FLOW: cfg.size = 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; -- 2.47.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-27 17:17:41.691940689 +0000 +++ 0109-common-mlx5-fix-misalignment.patch 2024-11-27 17:17:38.338269959 +0000 @@ -1 +1 @@ -From 90967539d0d1afcfd5237ed85efdc430359a0e6b Mon Sep 17 00:00:00 2001 +From a8403f04b0d04ac2e44e4d41c3f5d114014a353f Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 90967539d0d1afcfd5237ed85efdc430359a0e6b ] + @@ -38 +39,0 @@ -Cc: stable@dpdk.org @@ -49 +50 @@ -index c5eff7a0bf..9139bc6829 100644 +index 98e487e7ef..2b013254ad 100644 @@ -52 +53 @@ -@@ -132,5 +132,5 @@ struct mlx5_list_inconst { +@@ -131,5 +131,5 @@ struct mlx5_list_inconst { @@ -60 +61 @@ -index 210158350d..2d82807bc2 100644 +index 58aa72df64..fd5c8b5c72 100644 @@ -63 +64 @@ -@@ -942,5 +942,5 @@ struct mlx5_modification_cmd { +@@ -754,5 +754,5 @@ struct mlx5_modification_cmd { @@ -70 +71 @@ -@@ -953,5 +953,5 @@ struct mlx5_modification_cmd { +@@ -765,5 +765,5 @@ struct mlx5_modification_cmd { @@ -78 +79 @@ -index 52b90e6ff3..6e4473e2f4 100644 +index b339ccce84..20960b8b03 100644 @@ -81 +82 @@ -@@ -908,5 +908,5 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh) +@@ -832,5 +832,5 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh, @@ -83 +84 @@ - cfg.size = sh->config.dv_flow_en ? + cfg.size = config->dv_flow_en ?