Thread View: linux.kernel.netdev
6 messages
6 total messages
Started by Alexandre Cassen
Fri, 09 Oct 2026 05:20
[PATCH net-next 0/2] net/mlx5: less memory per offloaded tc rule
Author: Alexandre Cassen
Date: Fri, 09 Oct 2026 05:20
Date: Fri, 09 Oct 2026 05:20
20 lines
6347 bytes
6347 bytes
Two mlx5 allocations hold more memory than an offloaded tc rule needs. A NIC flow keeps a 4 KB allocation for parse attributes that nothing reads after offload. An FTE under hardware steering keeps the 1 KB action array it was built in while a rule rarely needs more than three entries. Freeing the first after offload saves 4 KB per NIC flow. Shrinking the second saves about 1 KB per FTE under hardware steering. Alexandre Cassen (2): net/mlx5e: TC, free NIC flow parse attributes after offload net/mlx5: HWS, shrink FTE action array to fit .../net/ethernet/mellanox/mlx5/core/en_tc.c | 18 +++++++++++++----- .../mellanox/mlx5/core/steering/hws/fs_hws.c | 10 +++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) -- 2.43.0
[PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload
Author: Alexandre Cassen
Date: Fri, 09 Oct 2026 05:21
Date: Fri, 09 Oct 2026 05:21
70 lines
7990 bytes
7990 bytes
A NIC flow holds a 4 KB allocation for its parse attributes until
deletion although nothing reads them after offload. Free them once the
rule is in.
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index c99e824b4c6d..708b7987ea4c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1414,6 +1414,16 @@ void mlx5e_del_offloaded_nic_rule(struct mlx5e_priv *priv,
MLX5E_TC_FT_LEVEL);
}
+static void mlx5e_tc_free_parse_attr(struct mlx5_flow_attr *attr)
+{
+ if (!attr->parse_attr)
+ return;
+
+ mlx5e_mod_hdr_dealloc(&attr->parse_attr->mod_hdr_acts);
+ kvfree(attr->parse_attr);
+ attr->parse_attr = NULL;
+}
+
static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow)
{
@@ -1436,10 +1446,8 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
}
mutex_unlock(&tc->t_lock);
- if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
- mlx5e_mod_hdr_dealloc(&attr->parse_attr->mod_hdr_acts);
+ if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
mlx5e_tc_detach_mod_hdr(priv, flow, attr);
- }
if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
mlx5_fc_destroy(priv->mdev, attr->counter);
@@ -1450,7 +1458,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
free_flow_post_acts(flow);
mlx5_tc_ct_delete_flow(get_ct_priv(flow->priv), attr);
- kvfree(attr->parse_attr);
+ mlx5e_tc_free_parse_attr(attr);
kfree(flow->attr);
}
@@ -4759,6 +4767,7 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,
if (err)
goto err_free;
+ mlx5e_tc_free_parse_attr(flow->attr);
flow_flag_set(flow, OFFLOADED);
*__flow = flow;
@@ -4766,7 +4775,6 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,
err_free:
flow_flag_set(flow, FAILED);
- mlx5e_mod_hdr_dealloc(&parse_attr->mod_hdr_acts);
mlx5e_flow_put(priv, flow);
out:
return err;
--
2.43.0
[PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit
Author: Alexandre Cassen
Date: Fri, 09 Oct 2026 05:21
Date: Fri, 09 Oct 2026 05:21
47 lines
7670 bytes
7670 bytes
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
Re: [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload
Author: Simon Horman
Date: Sat, 10 Oct 2026 15:42
Date: Sat, 10 Oct 2026 15:42
9 lines
5981 bytes
5981 bytes
On Fri, Oct 09, 2026 at 07:21:00AM +0200, Alexandre Cassen wrote: > A NIC flow holds a 4 KB allocation for its parse attributes until > deletion although nothing reads them after offload. Free them once the > rule is in. > > Signed-off-by: Alexandre Cassen <acassen@corp.free.fr> Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit
Author: Simon Horman
Date: Sat, 10 Oct 2026 15:42
Date: Sat, 10 Oct 2026 15:42
10 lines
6060 bytes
6060 bytes
On Fri, Oct 09, 2026 at 07:21:01AM +0200, Alexandre Cassen wrote: > 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> Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH net-next 0/2] net/mlx5: less memory per offloaded tc rule
Author: patchwork-bot+netdevbpf
Date: Thu, 15 Oct 2026 10:00
Date: Thu, 15 Oct 2026 10:00
28 lines
6616 bytes
6616 bytes
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Fri, 9 Oct 2026 07:20:59 +0200 you wrote:
> Two mlx5 allocations hold more memory than an offloaded tc rule needs.
> A NIC flow keeps a 4 KB allocation for parse attributes that nothing
> reads after offload. An FTE under hardware steering keeps the 1 KB
> action array it was built in while a rule rarely needs more than three
> entries.
>
> Freeing the first after offload saves 4 KB per NIC flow. Shrinking the
> second saves about 1 KB per FTE under hardware steering.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net/mlx5e: TC, free NIC flow parse attributes after offload
https://git.kernel.org/netdev/net-next/c/dd0425c502fc
- [net-next,2/2] net/mlx5: HWS, shrink FTE action array to fit
https://git.kernel.org/netdev/net-next/c/3636705910f9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads