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 086C245D5D for ; Thu, 21 Nov 2024 00:43:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEF0940296; Thu, 21 Nov 2024 00:43:31 +0100 (CET) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mails.dpdk.org (Postfix) with ESMTP id 65CCA40296 for ; Thu, 21 Nov 2024 00:43:30 +0100 (CET) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3824a8a5c56so159291f8f.3 for ; Wed, 20 Nov 2024 15:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732146210; x=1732751010; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PPOHADCpz4Er4Gfqm4dNEcoLV4cchHJbPqXdW9Czcrs=; b=SL87hya7VfHuCRdbH+dajUe1NrvPav/wgRx5b6cE0IGIv+gQdRFdBMNPvBSZV0wfYN tPEWs/JfJ8JHZiVECXd+0nq6MMzJyEi8Pcin8CTViJ9ESVmgppqKsrWRKZhxMT0IyqH9 86dOTDG0Nx2lGhhbHP0nb7sTc4+kqdnQKOeWibVme62Yh5NHiRPGF9EZ8PG9uAUzpZYH XoC0Vr7gFqYNbDd9Xg8VdntHhcCRnTTNF0FvPdUB3JccX5olxDYsLGTrJY6akU5zY9dU Gr2INidMwUSJjD7SeNIq+kIO7X0MePZFmU1DFAFaUYvjMFXGlGCRZLovhBIo2h1kmM7t mU1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732146210; x=1732751010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PPOHADCpz4Er4Gfqm4dNEcoLV4cchHJbPqXdW9Czcrs=; b=MhSj7mPW/e9rccw2+EgTD7VctZVgyA0Psgre/iAfBIonMZRtT85t3gpSJqLy/uLRMJ KDdSBUPq2pgYjso2AzF+/BTwcp8vkXCSwyDviPOklY2qmGhsQtQYiuhsfVopRqYLe0uX rezamafIIP2F02j2YiczdgA/N7ZpH0Q4+kdTlr26Br4nB+gH+rjr+Cj1FpOAZG6A+zd0 GpEPiJQOhoO/yp6YlSyBzKKMfF8H1ZfH+8g46tbutBaL9dnrOuF8d5TQuyTCRnsITDr8 nwn2BXKyVXK/LhB2eV033UZ9hg1JaBp0D9qXhtMfu/5q+qQxZ3732PhOoCBDnouKjzMh MCyw== X-Forwarded-Encrypted: i=1; AJvYcCV5wMApxVmnqir4x9AkXgnXvgXeobxgiQJ4WDW5KTnKHSc4/zx4VzfYX48x8s93YQqEs1cmw34=@dpdk.org X-Gm-Message-State: AOJu0Yw6uAHhj5VsIzTMMLBPvyUrvJscVNdEHZvKhJBEUETp3dV02AIo LkNHzxkPKpsl4ONdJMn4EI1EAAKww2TT+DhxxPXU8EjjwlVZPfpQ X-Gm-Gg: ASbGncuNYEEarjieyGRqxYKD5CQnNmX946bXva9gaSw0c2Rld2C71x1GLD8xEhT21P7 fJ0k60zUMNoDdUeiasjQ7Qn3rtx7WCbqIKR4Z/EZopJVfaX/NaGPQv+LCg0XcT3zr8WXASeAg9e wWcbNDFv4JfeHzEMuhO/P3zatkiMtCEwUXnqWFN9EVW3xuJVhuh1fzqbBlbFMKedUei9imq/Hq9 Df4H4fy6KZInWQPHAA0euiqOQ88XfiwSWqgU6TFQGpSU8rVwPJ10vKl X-Google-Smtp-Source: AGHT+IG3r/uMGyKU6CgVESYmCPr5QedKjzm7xMcuu9+2doikpjUI2Jdu5opOP1HptyxbFA3aEXQk/Q== X-Received: by 2002:a05:6000:1ac8:b0:37d:4c8f:2e1 with SMTP id ffacd0b85a97d-38254af6498mr3823768f8f.22.1732146209882; Wed, 20 Nov 2024 15:43:29 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:21cd:def0:a01d:d2aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825490cb88sm3345404f8f.41.2024.11.20.15.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 15:43:28 -0800 (PST) From: luca.boccassi@gmail.com To: Shani Peretz Cc: Bing Zhao , dpdk stable Subject: patch 'common/mlx5: fix misalignment' has been queued to stable release 22.11.7 Date: Wed, 20 Nov 2024 23:41:44 +0000 Message-ID: <20241120234215.233355-19-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241120234215.233355-1-luca.boccassi@gmail.com> References: <20241112220754.666489-40-luca.boccassi@gmail.com> <20241120234215.233355-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/22/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/102f2042b2c0c3ea222274c00078913e5b026774 Thanks. Luca Boccassi --- >From 102f2042b2c0c3ea222274c00078913e5b026774 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 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 696c59d0fd..cf525c14df 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -811,7 +811,7 @@ struct mlx5_modification_cmd { unsigned int field:12; unsigned int action_type:4; }; - }; + } __rte_packed; union { uint32_t data1; uint8_t data[4]; @@ -822,7 +822,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 1076ad1721..94873dfe89 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -904,7 +904,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.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-20 23:41:23.383088625 +0000 +++ 0019-common-mlx5-fix-misalignment.patch 2024-11-20 23:41:22.736195467 +0000 @@ -1 +1 @@ -From 90967539d0d1afcfd5237ed85efdc430359a0e6b Mon Sep 17 00:00:00 2001 +From 102f2042b2c0c3ea222274c00078913e5b026774 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 ae15119a33..6db0105c53 100644 @@ -62 +63 @@ -index 210158350d..2d82807bc2 100644 +index 696c59d0fd..cf525c14df 100644 @@ -65 +66 @@ -@@ -941,7 +941,7 @@ struct mlx5_modification_cmd { +@@ -811,7 +811,7 @@ struct mlx5_modification_cmd { @@ -74 +75 @@ -@@ -952,7 +952,7 @@ struct mlx5_modification_cmd { +@@ -822,7 +822,7 @@ struct mlx5_modification_cmd { @@ -84 +85 @@ -index 52b90e6ff3..6e4473e2f4 100644 +index 1076ad1721..94873dfe89 100644 @@ -87 +88 @@ -@@ -907,7 +907,7 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh) +@@ -904,7 +904,7 @@ mlx5_flow_ipool_create(struct mlx5_dev_ctx_shared *sh)