* [PATCH 0/1] net/mlx5/core: Fix stack frame size warnings
@ 2026-02-26 9:28 Cheng-Yang Chou
2026-02-26 9:28 ` [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap Cheng-Yang Chou
0 siblings, 1 reply; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-02-26 9:28 UTC (permalink / raw)
To: netdev, saeedm, tariqt, mbloch; +Cc: jserv, charlie910417, yphbchou0911
Hi,
This patch resolves stack frame size warnings in the mlx5 driver by
dynamically allocating 'struct ttc_params'. The structure exceeds the
1024-byte limit, which risks causing stack overflows in deep execution paths.
While compiling the kernel, I encountered the following warnings:
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c: In function ‘mlx5_lag_create_inner_ttc_table’:
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c:543:1: warning: the frame size of 1104 bytes is larger than 1024 bytes [-Wframe-larger-than=]
543 | }
| ^
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c: In function ‘mlx5_lag_create_ttc_table’:
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c:527:1: warning: the frame size of 1104 bytes is larger than 1024 bytes [-Wframe-larger-than=]
527 | }
| ^
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c: In function ‘mlx5e_create_rep_ttc_table’:
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:991:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
991 | }
| ^
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function ‘mlx5e_hairpin_rss_init’:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:890:1: warning: the frame size of 1280 bytes is larger than 1024 bytes [-Wframe-larger-than=]
890 | }
| ^
Thanks,
Cheng-Yang
---
Cheng-Yang Chou (1):
net/mlx5/core: Allocate ttc_params on heap
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++----
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 ++++++++++---
.../mellanox/mlx5/core/lag/port_sel.c | 22 ++++++++++++++-----
3 files changed, 39 insertions(+), 13 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap
2026-02-26 9:28 [PATCH 0/1] net/mlx5/core: Fix stack frame size warnings Cheng-Yang Chou
@ 2026-02-26 9:28 ` Cheng-Yang Chou
2026-02-26 10:05 ` Leon Romanovsky
2026-02-26 18:15 ` Simon Horman
0 siblings, 2 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-02-26 9:28 UTC (permalink / raw)
To: netdev, saeedm, tariqt, mbloch; +Cc: jserv, charlie910417, yphbchou0911
The ttc_params structure is too large to be allocated on the stack,
triggering warnings for exceeding the 1024-byte frame size limit.
Consuming excessive stack space risks causing stack overflows.
Allocate the structure dynamically to maintain safe stack boundaries.
Signed-off-by: Po-Ying Chiu <charlie910417@gmail.com>
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
.../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++----
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 ++++++++++---
.../mellanox/mlx5/core/lag/port_sel.c | 22 ++++++++++++++-----
3 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 6eec88fa6d10..8e3862f5b563 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -966,27 +966,34 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
int err;
+ ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
+ if (!ttc_params)
+ return -ENOMEM;
+
mlx5e_fs_set_ns(priv->fs,
mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL), false);
/* The inner_ttc in the ttc params is intentionally not set */
- mlx5e_set_ttc_params(priv->fs, priv->rx_res, &ttc_params, false, false);
+ mlx5e_set_ttc_params(priv->fs, priv->rx_res, ttc_params, false, false);
if (rep->vport != MLX5_VPORT_UPLINK)
/* To give uplik rep TTC a lower level for chaining from root ft */
- ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
+ ttc_params->ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
- mlx5e_fs_set_ttc(priv->fs, mlx5_create_ttc_table(priv->mdev, &ttc_params), false);
+ mlx5e_fs_set_ttc(priv->fs, mlx5_create_ttc_table(priv->mdev, ttc_params), false);
if (IS_ERR(mlx5e_fs_get_ttc(priv->fs, false))) {
err = PTR_ERR(mlx5e_fs_get_ttc(priv->fs, false));
netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n",
err);
+ kfree(ttc_params);
return err;
}
+
+ kfree(ttc_params);
return 0;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 424786f489ec..83a6fd052155 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -855,7 +855,7 @@ static void mlx5e_hairpin_set_ttc_params(struct mlx5e_hairpin *hp,
static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
{
struct mlx5e_priv *priv = hp->func_priv;
- struct ttc_params ttc_params;
+ struct ttc_params *ttc_params;
struct mlx5_ttc_table *ttc;
int err;
@@ -867,8 +867,14 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
if (err)
goto err_create_indirect_tirs;
- mlx5e_hairpin_set_ttc_params(hp, &ttc_params);
- hp->ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
+ ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
+ if (!ttc_params) {
+ err = -ENOMEM;
+ goto err_alloc_ttc_params;
+ }
+
+ mlx5e_hairpin_set_ttc_params(hp, ttc_params);
+ hp->ttc = mlx5_create_ttc_table(priv->mdev, ttc_params);
if (IS_ERR(hp->ttc)) {
err = PTR_ERR(hp->ttc);
goto err_create_ttc_table;
@@ -879,9 +885,12 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
hp->num_channels,
mlx5_get_ttc_flow_table(ttc)->id);
+ kfree(ttc_params);
return 0;
err_create_ttc_table:
+ kfree(ttc_params);
+err_alloc_ttc_params:
mlx5e_hairpin_destroy_indirect_tirs(hp);
err_create_indirect_tirs:
mlx5e_rqt_destroy(&hp->indir_rqt);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
index d832a12ffec0..69fc596e9188 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c
@@ -514,15 +514,20 @@ static int mlx5_lag_create_ttc_table(struct mlx5_lag *ldev)
{
int first_idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct mlx5_lag_port_sel *port_sel = &ldev->port_sel;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
struct mlx5_core_dev *dev;
if (first_idx < 0)
return -EINVAL;
+ ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
+ if (!ttc_params)
+ return -ENOMEM;
+
dev = ldev->pf[first_idx].dev;
- mlx5_lag_set_outer_ttc_params(ldev, &ttc_params);
- port_sel->outer.ttc = mlx5_create_ttc_table(dev, &ttc_params);
+ mlx5_lag_set_outer_ttc_params(ldev, ttc_params);
+ port_sel->outer.ttc = mlx5_create_ttc_table(dev, ttc_params);
+ kfree(ttc_params);
return PTR_ERR_OR_ZERO(port_sel->outer.ttc);
}
@@ -530,15 +535,20 @@ static int mlx5_lag_create_inner_ttc_table(struct mlx5_lag *ldev)
{
int first_idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct mlx5_lag_port_sel *port_sel = &ldev->port_sel;
- struct ttc_params ttc_params = {};
+ struct ttc_params *ttc_params;
struct mlx5_core_dev *dev;
if (first_idx < 0)
return -EINVAL;
+ ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
+ if (!ttc_params)
+ return -ENOMEM;
+
dev = ldev->pf[first_idx].dev;
- mlx5_lag_set_inner_ttc_params(ldev, &ttc_params);
- port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, &ttc_params);
+ mlx5_lag_set_inner_ttc_params(ldev, ttc_params);
+ port_sel->inner.ttc = mlx5_create_inner_ttc_table(dev, ttc_params);
+ kfree(ttc_params);
return PTR_ERR_OR_ZERO(port_sel->inner.ttc);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap
2026-02-26 9:28 ` [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap Cheng-Yang Chou
@ 2026-02-26 10:05 ` Leon Romanovsky
2026-02-26 10:33 ` Cheng-Yang Chou
2026-02-26 18:15 ` Simon Horman
1 sibling, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2026-02-26 10:05 UTC (permalink / raw)
To: Cheng-Yang Chou; +Cc: netdev, saeedm, tariqt, mbloch, jserv, charlie910417
On Thu, Feb 26, 2026 at 05:28:55PM +0800, Cheng-Yang Chou wrote:
> The ttc_params structure is too large to be allocated on the stack,
> triggering warnings for exceeding the 1024-byte frame size limit.
> Consuming excessive stack space risks causing stack overflows.
>
> Allocate the structure dynamically to maintain safe stack boundaries.
>
> Signed-off-by: Po-Ying Chiu <charlie910417@gmail.com>
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++----
> .../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 ++++++++++---
> .../mellanox/mlx5/core/lag/port_sel.c | 22 ++++++++++++++-----
> 3 files changed, 39 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index 6eec88fa6d10..8e3862f5b563 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -966,27 +966,34 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
> {
> struct mlx5e_rep_priv *rpriv = priv->ppriv;
> struct mlx5_eswitch_rep *rep = rpriv->rep;
> - struct ttc_params ttc_params = {};
> + struct ttc_params *ttc_params;
> int err;
>
> + ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
It needs to be kzalloc_obj(*ttc_params).
https://lore.kernel.org/linux-rdma/20260226071913.GD12611@unreal/T/#u
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap
2026-02-26 10:05 ` Leon Romanovsky
@ 2026-02-26 10:33 ` Cheng-Yang Chou
0 siblings, 0 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-02-26 10:33 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: netdev, saeedm, tariqt, mbloch, jserv, charlie910417
On Thu, Feb 26, 2026 at 12:05:14PM +0200, Leon Romanovsky wrote:
> > + ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
>
> It needs to be kzalloc_obj(*ttc_params).
> https://lore.kernel.org/linux-rdma/20260226071913.GD12611@unreal/T/#u
>
> Thanks
Thanks for the head-up. I'll send a v2 patch.
Thanks,
Cheng-Yang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap
2026-02-26 9:28 ` [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap Cheng-Yang Chou
2026-02-26 10:05 ` Leon Romanovsky
@ 2026-02-26 18:15 ` Simon Horman
2026-02-27 2:38 ` Cheng-Yang Chou
1 sibling, 1 reply; 6+ messages in thread
From: Simon Horman @ 2026-02-26 18:15 UTC (permalink / raw)
To: Cheng-Yang Chou; +Cc: netdev, saeedm, tariqt, mbloch, jserv, charlie910417
On Thu, Feb 26, 2026 at 05:28:55PM +0800, Cheng-Yang Chou wrote:
> The ttc_params structure is too large to be allocated on the stack,
> triggering warnings for exceeding the 1024-byte frame size limit.
> Consuming excessive stack space risks causing stack overflows.
>
> Allocate the structure dynamically to maintain safe stack boundaries.
>
> Signed-off-by: Po-Ying Chiu <charlie910417@gmail.com>
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
> ---
> .../net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++++++----
> .../net/ethernet/mellanox/mlx5/core/en_tc.c | 15 ++++++++++---
> .../mellanox/mlx5/core/lag/port_sel.c | 22 ++++++++++++++-----
> 3 files changed, 39 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index 6eec88fa6d10..8e3862f5b563 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -966,27 +966,34 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
> {
> struct mlx5e_rep_priv *rpriv = priv->ppriv;
> struct mlx5_eswitch_rep *rep = rpriv->rep;
> - struct ttc_params ttc_params = {};
> + struct ttc_params *ttc_params;
> int err;
>
> + ttc_params = kzalloc(sizeof(*ttc_params), GFP_KERNEL);
> + if (!ttc_params)
> + return -ENOMEM;
> +
Please use tabs (8 characters wide) rather than spaces
for indentation throughout this patch.
--
pw-bot: changes-requested
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap
2026-02-26 18:15 ` Simon Horman
@ 2026-02-27 2:38 ` Cheng-Yang Chou
0 siblings, 0 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-02-27 2:38 UTC (permalink / raw)
To: Simon Horman; +Cc: netdev, saeedm, tariqt, mbloch, jserv, charlie910417
On Thu, Feb 26, 2026 at 06:15:51PM +0000, Simon Horman wrote:
>
> Please use tabs (8 characters wide) rather than spaces
> for indentation throughout this patch.
>
> --
Thanks for the review. This issue has been addressed in v3:
https://lore.kernel.org/all/20260226174601.2120282-1-yphbchou0911@gmail.com/
Thanks,
Cheng-Yang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-27 2:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 9:28 [PATCH 0/1] net/mlx5/core: Fix stack frame size warnings Cheng-Yang Chou
2026-02-26 9:28 ` [PATCH 1/1] net/mlx5/core: Allocate ttc_params on heap Cheng-Yang Chou
2026-02-26 10:05 ` Leon Romanovsky
2026-02-26 10:33 ` Cheng-Yang Chou
2026-02-26 18:15 ` Simon Horman
2026-02-27 2:38 ` Cheng-Yang Chou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox