Netdev List
 help / color / mirror / Atom feed
From: Alexandre Cassen <acassen@corp.free.fr>
To: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Moshe Shemesh <moshe@nvidia.com>,
	Yevgeny Kliteynik <kliteyn@nvidia.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit
Date: Fri,  9 Oct 2026 07:21:01 +0200	[thread overview]
Message-ID: <20261009052103.3621855-3-acassen@corp.free.fr> (raw)
In-Reply-To: <20261009052103.3621855-1-acassen@corp.free.fr>

An FTE keeps the actions it must release in the array used to build
them. This is a 1 KB allocation sized for MLX5_FLOW_CONTEXT_ACTION_MAX
entries while a rule rarely needs more than three. Keep a copy sized to
the actions in use.

Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
 .../ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
index 5a172c572a68..da6e57c103d6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
@@ -746,6 +746,7 @@ static int mlx5_fs_fte_get_hws_actions(struct mlx5_flow_root_namespace *ns,
 	struct mlx5_fs_hws_context *fs_ctx = &ns->fs_hws_context;
 	struct mlx5hws_action_dest_attr *dest_actions;
 	struct mlx5hws_context *ctx = fs_ctx->hws_ctx;
+	struct mlx5_fs_hws_rule_action *rule_actions;
 	struct mlx5_fs_hws_rule_action *fs_actions;
 	struct mlx5_core_dev *dev = ns->dev;
 	struct mlx5hws_action *dest_action;
@@ -1041,13 +1042,20 @@ static int mlx5_fs_fte_get_hws_actions(struct mlx5_flow_root_namespace *ns,
 	fs_actions[num_fs_actions++].action = tmp_action;
 	(*ractions)[num_actions++].action = tmp_action;
 
+	rule_actions = kmemdup_array(fs_actions, num_fs_actions,
+				     sizeof(*fs_actions), GFP_KERNEL);
+	if (!rule_actions) {
+		err = -ENOMEM;
+		goto free_actions;
+	}
+	kfree(fs_actions);
 	kfree(dest_actions);
 
 	/* Actions created specifically for this rule will be destroyed
 	 * once rule is deleted.
 	 */
 	fte->fs_hws_rule.num_fs_actions = num_fs_actions;
-	fte->fs_hws_rule.hws_fs_actions = fs_actions;
+	fte->fs_hws_rule.hws_fs_actions = rule_actions;
 
 	return 0;
 
-- 
2.43.0


  parent reply	other threads:[~2026-10-09  5:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  5:20 [PATCH net-next 0/2] net/mlx5: less memory per offloaded tc rule Alexandre Cassen
2026-10-09  5:21 ` [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload Alexandre Cassen
2026-10-10 15:42   ` Simon Horman
2026-10-09  5:21 ` Alexandre Cassen [this message]
2026-10-10 15:42   ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261009052103.3621855-3-acassen@corp.free.fr \
    --to=acassen@corp.free.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox