* [PATCH net-next 0/2] net/mlx5: less memory per offloaded tc rule @ 2026-10-09 5:20 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-09 5:21 ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Alexandre Cassen 0 siblings, 2 replies; 7+ messages in thread From: Alexandre Cassen @ 2026-10-09 5:20 UTC (permalink / raw) To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Moshe Shemesh, Yevgeny Kliteynik, netdev, linux-rdma 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload 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 ` Alexandre Cassen 2026-10-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman 2026-10-09 5:21 ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Alexandre Cassen 1 sibling, 2 replies; 7+ messages in thread From: Alexandre Cassen @ 2026-10-09 5:21 UTC (permalink / raw) To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Moshe Shemesh, Yevgeny Kliteynik, netdev, linux-rdma 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload 2026-10-09 5:21 ` [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload Alexandre Cassen @ 2026-10-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-10-09 5:34 UTC (permalink / raw) To: Alexandre Cassen; +Cc: linux-rdma > 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> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/20261009052103.3621855-1-acassen@corp.free.fr?part=1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload 2026-10-09 5:21 ` [PATCH net-next 1/2] net/mlx5e: TC, free NIC flow parse attributes after offload Alexandre Cassen 2026-10-09 5:34 ` sashiko-bot @ 2026-10-10 15:42 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: Simon Horman @ 2026-10-10 15:42 UTC (permalink / raw) To: Alexandre Cassen Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Moshe Shemesh, Yevgeny Kliteynik, netdev, linux-rdma 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> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit 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-09 5:21 ` Alexandre Cassen 2026-10-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman 1 sibling, 2 replies; 7+ messages in thread From: Alexandre Cassen @ 2026-10-09 5:21 UTC (permalink / raw) To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Moshe Shemesh, Yevgeny Kliteynik, netdev, linux-rdma 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit 2026-10-09 5:21 ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Alexandre Cassen @ 2026-10-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-10-09 5:34 UTC (permalink / raw) To: Alexandre Cassen; +Cc: linux-rdma > 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> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/20261009052103.3621855-1-acassen@corp.free.fr?part=2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit 2026-10-09 5:21 ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Alexandre Cassen 2026-10-09 5:34 ` sashiko-bot @ 2026-10-10 15:42 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: Simon Horman @ 2026-10-10 15:42 UTC (permalink / raw) To: Alexandre Cassen Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Moshe Shemesh, Yevgeny Kliteynik, netdev, linux-rdma 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> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-10 15:42 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman 2026-10-09 5:21 ` [PATCH net-next 2/2] net/mlx5: HWS, shrink FTE action array to fit Alexandre Cassen 2026-10-09 5:34 ` sashiko-bot 2026-10-10 15:42 ` Simon Horman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox