mlx5 misc fixes 2025-05-22
Subsystems (5)
Tariq Toukan
maintainercover mlx5 misc fixes 2025-05-22
Hi,
This small patchset provides misc bug fixes from the team to the mlx5 core and EN drivers.
Thanks,
Tariq.
Jianbo Liu (1):
net/mlx5e: Fix leak of Geneve TLV option object
Moshe Shemesh (1):
net/mlx5: Ensure fw pages are always allocated on same NUMA
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++--- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
base-commit: 407e0efdf8baf1672876d5948b75049860a93e59
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH 1/2 net/mlx5: Ensure fw pages are always allocated on same NUMA
From: Moshe Shemesh <[email protected]>
When firmware asks the driver to allocate more pages, using event of give_pages, the driver should always allocate it from same NUMA, the original device NUMA. Current code uses dev_to_node() which can result in different NUMA as it is changed by other driver flows, such as mlx5_dma_zalloc_coherent_node(). Instead, use saved numa node for allocating firmware pages.
--- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +1 -1
@@ -291,7 +291,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr, u32 function)static int alloc_system_page (struct mlx5_core_dev *dev,u32 function) {struct device *device =mlx5_core_dma_dev (dev); -int nid =dev_to_node (device); +int nid = dev->priv.numa_node;struct page *page;u64 zero_addr =1 ;u64 addr;
Signature · 1 line
2.31.1
Re: [PATCH net 1/2] net/mlx5: Ensure fw pages are always allocated on same NUMA
Quoted 21 lines · Tariq Toukan
From: Moshe Shemesh <[email protected]>
When firmware asks the driver to allocate more pages, using event of
give_pages, the driver should always allocate it from same NUMA, the original device NUMA. Current code usesdev_to_node()which can result in different NUMA as it is changed by other driver flows, such asmlx5_dma_zalloc_coherent_node(). Instead, use saved numa node for allocating firmware pages.Fixes 311c7c71c9bb ("net/mlx5e: Allocate DMA coherent memory on reader NUMA node")Signed-off-by Moshe Shemesh <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c static void free_4k(struct mlx5_core_dev *dev, u64 addr, u32 function) · line 294
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +1
-1@@ -291,7 +291,7 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr, u32 function)static int alloc_system_page (struct mlx5_core_dev *dev,u32 function) {struct device *device =mlx5_core_dma_dev (dev); -int nid =dev_to_node (device); +int nid = dev->priv.numa_node;
Thanks,
Dawid
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +0
-0struct page *page;u64 zero_addr =1 ;u64 addr;
Tariq Toukan
maintainerPATCH 2/2 net/mlx5e: Fix leak of Geneve TLV option object
In reply to Tariq ToukanFrom: Jianbo Liu <[email protected]>
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary mlx5_flow_spec is used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporary mlx5_flow_spec is directly freed after parsing, which causes the leak because no information regarding the object is saved in flow's mlx5_flow_spec, which is used to free the object when deleting the flow.
To fix the leak, call mlx5_geneve_tlv_option_del() before free the temporary spec if it has TLV object.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -3
@@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,return err; } -static bool mlx5_flow_has_geneve_opt (struct mlx5e_tc_flow *flow) +static bool mlx5_flow_has_geneve_opt (struct mlx5_flow_spec *spec) { -struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters_3);
@@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }complete_all (&flow->del_hw_done); -if (mlx5_flow_has_geneve_opt (flow)) +if (mlx5_flow_has_geneve_opt (&attr->parse_attr->spec))mlx5_geneve_tlv_option_del (priv->mdev->geneve);if (flow->decap_route)
@@ -2580,6 +2579,8 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,return err; } err =mlx5e_tc_set_attr_rx_tun (flow, tmp_spec); +if (mlx5_flow_has_geneve_opt (tmp_spec)) +mlx5_geneve_tlv_option_del (priv->mdev->geneve);kvfree (tmp_spec);if (err)return err;
Signature · 1 line
2.31.1
Simon Horman
reviewerRe: [PATCH net 2/2] net/mlx5e: Fix leak of Geneve TLV option object
Quoted 40 lines · Tariq Toukan
From: Jianbo Liu <[email protected]>
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary
mlx5_flow_specis used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporarymlx5_flow_specis directly freed after parsing, which causes the leak because no information regarding the object is saved in flow'smlx5_flow_spec, which is used to free the object when deleting the flow.To fix the leak, call
mlx5_geneve_tlv_option_del()before free the temporary spec if it has TLV object.Fixes 521933cdc4aa ("net/mlx5e: Support Geneve and GRE with VF tunnel offload")Signed-off-by Jianbo Liu <[email protected]>Reviewed-by Cosmin Ratiu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-2@@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,return err; } -static bool mlx5_flow_has_geneve_opt (struct mlx5e_tc_flow *flow) +static bool mlx5_flow_has_geneve_opt (struct mlx5_flow_spec *spec) { -struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters_3);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, · line 2074
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-1@@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }complete_all (&flow->del_hw_done); -if (mlx5_flow_has_geneve_opt (flow)) +if (mlx5_flow_has_geneve_opt (&attr->parse_attr->spec))mlx5_geneve_tlv_option_del (priv->mdev->geneve);if (flow->decap_route)
Hi,
The lines leading up to the hung below are:
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level);
if (err) {
kvfree(tmp_spec);
NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes");
netdev_warn(priv->netdev, "Failed to parse tunnel attributes");I am wondering if the same resource leak described in the patch description can occur if mlx5e_tc_tun_parse() fails after it successfully calls tunnel->parse_tunnel().
Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2
-0@@ -2580,6 +2579,8 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,return err; } err =mlx5e_tc_set_attr_rx_tun (flow, tmp_spec); +if (mlx5_flow_has_geneve_opt (tmp_spec)) +mlx5_geneve_tlv_option_del (priv->mdev->geneve);kvfree (tmp_spec);if (err)return err;Signature · 1 line
2.31.1
Re: [PATCH net 2/2] net/mlx5e: Fix leak of Geneve TLV option object
Quoted 60 lines · Simon Horman
Quoted 40 lines · Tariq Toukan
From: Jianbo Liu <[email protected]>
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary
mlx5_flow_specis used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporarymlx5_flow_specis directly freed after parsing, which causes the leak because no information regarding the object is saved in flow'smlx5_flow_spec, which is used to free the object when deleting the flow.To fix the leak, call
mlx5_geneve_tlv_option_del()before free the temporary spec if it has TLV object.Fixes 521933cdc4aa ("net/mlx5e: Support Geneve and GRE with VF tunnel offload")Signed-off-by Jianbo Liu <[email protected]>Reviewed-by Cosmin Ratiu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-2@@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,return err; } -static bool mlx5_flow_has_geneve_opt (struct mlx5e_tc_flow *flow) +static bool mlx5_flow_has_geneve_opt (struct mlx5_flow_spec *spec) { -struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters_3);drivers/net/ethernet/mellanox/mlx5/core/en_tc.c static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, · line 2074
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-1@@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }complete_all (&flow->del_hw_done); -if (mlx5_flow_has_geneve_opt (flow)) +if (mlx5_flow_has_geneve_opt (&attr->parse_attr->spec))mlx5_geneve_tlv_option_del (priv->mdev->geneve);if (flow->decap_route)Hi,
The lines leading up to the hung below are:
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level); if (err) { kvfree(tmp_spec); NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes"); netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
Quoted 4 lines
I am wondering if the same resource leak described in the patch description can occur if
mlx5e_tc_tun_parse()fails after it successfully callstunnel->parse_tunnel().
Yes, I missed that. I will fix in next version.
Thanks!
Jianbo
Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2
-0@@ -2580,6 +2579,8 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,return err; } err =mlx5e_tc_set_attr_rx_tun (flow, tmp_spec); +if (mlx5_flow_has_geneve_opt (tmp_spec)) +mlx5_geneve_tlv_option_del (priv->mdev->geneve);kvfree (tmp_spec);if (err)return err;Signature · 1 line
2.31.1
Simon Horman
reviewerRe: [PATCH net 2/2] net/mlx5e: Fix leak of Geneve TLV option object
Quoted 60 lines · Jianbo Liu
Quoted 57 lines · Simon Horman
Quoted 39 lines · Tariq Toukan
From: Jianbo Liu <[email protected]>
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary
mlx5_flow_specis used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporarymlx5_flow_specis directly freed after parsing, which causes the leak because no information regarding the object is saved in flow'smlx5_flow_spec, which is used to free the object when deleting the flow.To fix the leak, call
mlx5_geneve_tlv_option_del()before free the temporary spec if it has TLV object.Fixes 521933cdc4aa ("net/mlx5e: Support Geneve and GRE with VF tunnel offload")Signed-off-by Jianbo Liu <[email protected]>Reviewed-by Cosmin Ratiu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-2@@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,return err; } -static bool mlx5_flow_has_geneve_opt (struct mlx5e_tc_flow *flow) +static bool mlx5_flow_has_geneve_opt (struct mlx5_flow_spec *spec) { -struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters_3);drivers/net/ethernet/mellanox/mlx5/core/en_tc.c static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, · line 2072
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1
-1@@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, }complete_all (&flow->del_hw_done); -if (mlx5_flow_has_geneve_opt (flow)) +if (mlx5_flow_has_geneve_opt (&attr->parse_attr->spec))mlx5_geneve_tlv_option_del (priv->mdev->geneve);if (flow->decap_route)Hi,
The lines leading up to the hung below are:
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level); if (err) { kvfree(tmp_spec); NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes"); netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
Quoted 6 lines
Quoted 4 lines
I am wondering if the same resource leak described in the patch description can occur if
mlx5e_tc_tun_parse()fails after it successfully callstunnel->parse_tunnel().Yes, I missed that. I will fix in next version.
Thanks, much appreciated.