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 28AC246211 for ; Thu, 13 Feb 2025 11:00:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 23C6040287; Thu, 13 Feb 2025 11:00:40 +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 5BBC542ED2 for ; Thu, 13 Feb 2025 11:00:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739440837; 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=LwlhVGmG3mQ+DbDb+jQuDh7mLoopp9pwiMrrzWETXC4=; b=c23Rqpx1tfwTjNdvrdbhv7J1LrAxm6QUjFoTZdUVoL4Uf/2Y/rqIqhY37FPOX0l2I4Ik0U Iv+i5aJo/HAjRnKEO01loRaxYDBniAcTIpzSP1gzk/uSoGs/cTnl0zImXBXS2N5tsGiu3B gKjbf/lKX4fU969GpBqqkW8YwIEX3w4= 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-202-Zgbc-HaqMXq3BBwuuxJTMg-1; Thu, 13 Feb 2025 05:00:36 -0500 X-MC-Unique: Zgbc-HaqMXq3BBwuuxJTMg-1 X-Mimecast-MFC-AGG-ID: Zgbc-HaqMXq3BBwuuxJTMg_1739440835 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 5EC3E18D95EA; Thu, 13 Feb 2025 10:00:35 +0000 (UTC) Received: from rh.Home (unknown [10.45.224.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CB83C1800365; Thu, 13 Feb 2025 10:00:33 +0000 (UTC) From: Kevin Traynor To: Bing Zhao Cc: Dariusz Sosnowski , dpdk stable Subject: patch 'net/mlx5: fix unneeded stub flow table allocation' has been queued to stable release 24.11.2 Date: Thu, 13 Feb 2025 09:57:49 +0000 Message-ID: <20250213095933.362078-22-ktraynor@redhat.com> In-Reply-To: <20250213095933.362078-1-ktraynor@redhat.com> References: <20250213095933.362078-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: t3oyPkCyZG27K3qM2MKTccPYLYzMSFn7QoTmgybjJu0_1739440835 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.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/17/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/a3ee0fe3555b8cc0daa6bf2a68002c7f73845785 Thanks. Kevin --- >From a3ee0fe3555b8cc0daa6bf2a68002c7f73845785 Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Tue, 26 Nov 2024 11:25:39 +0200 Subject: [PATCH] net/mlx5: fix unneeded stub flow table allocation [ upstream commit 3cd695c34528571c378c5f6be7ff81d3cca9a84c ] The HWS non-template flow API is reusing some implementation of template API to unify code logic. So for each rule creation, a stub / temporary table is used in order to reuse the actions construction. Since this is temporary and used only internally, there is no need to save the table permanently. Only parts of them are mandatory, so the allocation / free from the heap of RTE memory is a waste and causes a lot of overhead. By using the pre-allocated workspace and set the needed fields expliticly will save the overhead and help to speed up the rule insertion rate. Fixes: 27d171b88031 ("net/mlx5: abstract flow action and enable reconfigure") Signed-off-by: Bing Zhao Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_flow.c | 11 +++++++++-- drivers/net/mlx5/mlx5_flow.h | 3 +++ drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++-------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 16ddd05448..9203643300 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -8271,6 +8271,10 @@ flow_alloc_thread_workspace(void) size_t data_size = RTE_ALIGN(sizeof(struct mlx5_flow_workspace), sizeof(long)); size_t rss_queue_array_size = sizeof(uint16_t) * RTE_ETH_RSS_RETA_SIZE_512; - struct mlx5_flow_workspace *data = calloc(1, data_size + - rss_queue_array_size); + size_t alloc_size = data_size + rss_queue_array_size; +#ifdef HAVE_MLX5_HWS_SUPPORT + /* Dummy table size for the non-template API. */ + alloc_size += sizeof(struct rte_flow_template_table); +#endif + struct mlx5_flow_workspace *data = calloc(1, alloc_size); if (!data) { @@ -8279,4 +8283,7 @@ flow_alloc_thread_workspace(void) } data->rss_desc.queue = RTE_PTR_ADD(data, data_size); +#ifdef HAVE_MLX5_HWS_SUPPORT + data->table = RTE_PTR_ADD(data->rss_desc.queue, rss_queue_array_size); +#endif return data; } diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index bcc2782460..757bbf73c1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1920,4 +1920,7 @@ struct mlx5_flow_workspace { struct mlx5_flow_meter_policy *final_policy; /* The final policy when meter policy is hierarchy. */ +#ifdef HAVE_MLX5_HWS_SUPPORT + struct rte_flow_template_table *table; +#endif uint32_t skip_matcher_reg:1; /* Indicates if need to skip matcher register in translate. */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 1de6b889a7..2b62711413 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -13518,5 +13518,4 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, uint32_t src_group = 0; enum mlx5dr_table_type table_type; - struct rte_flow_template_table *table = NULL; struct mlx5_flow_group grp; struct rte_flow_actions_template *at = NULL; @@ -13532,4 +13531,8 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, memset(masks, 0, sizeof(masks)); memset(mask_conf, 0, sizeof(mask_conf)); + /* Only set the needed fields explicitly. */ + struct mlx5_flow_workspace *wks = mlx5_flow_push_thread_workspace(); + struct rte_flow_template_table *table; + /* * Notice All direct actions will be unmasked, @@ -13541,4 +13544,10 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, * and not during action construct. */ + if (!wks) + return rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "failed to push flow workspace"); + table = wks->table; flow_nta_build_template_mask(actions, masks, mask_conf); /* The group in the attribute translation was done in advance. */ @@ -13552,9 +13561,4 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, else table_type = MLX5DR_TABLE_TYPE_NIC_RX; - /* TODO: consider to reuse the workspace per thread. */ - table = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*table), 0, SOCKET_ID_ANY); - if (!table) - return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION, - actions, "Failed to allocate dummy table"); at = __flow_hw_actions_template_create(dev, &template_attr, actions, masks, true, error); if (!at) { @@ -13593,8 +13597,7 @@ end: else __flow_hw_act_data_flush(dev, hw_acts); - if (table) - mlx5_free(table); if (at) mlx5_free(at); + mlx5_flow_pop_thread_workspace(); return ret; } -- 2.48.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-02-12 17:29:36.941546295 +0000 +++ 0022-net-mlx5-fix-unneeded-stub-flow-table-allocation.patch 2025-02-12 17:29:34.258945381 +0000 @@ -1 +1 @@ -From 3cd695c34528571c378c5f6be7ff81d3cca9a84c Mon Sep 17 00:00:00 2001 +From a3ee0fe3555b8cc0daa6bf2a68002c7f73845785 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 3cd695c34528571c378c5f6be7ff81d3cca9a84c ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org @@ -54 +55 @@ -index 50b0e2ce47..93c2406abc 100644 +index bcc2782460..757bbf73c1 100644