netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Jacob Keller <jacob.e.keller@intel.com>
Subject: [net-next 01/15] mlx5: reduce stack usage in mlx5_setup_tc
Date: Tue,  7 Feb 2023 16:36:58 -0800	[thread overview]
Message-ID: <20230208003712.68386-2-saeed@kernel.org> (raw)
In-Reply-To: <20230208003712.68386-1-saeed@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

Clang warns about excessive stack usage on 32-bit targets:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:3597:12: error: stack frame size (1184) exceeds limit (1024) in 'mlx5e_setup_tc' [-Werror,-Wframe-larger-than]
static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,

It turns out that both the mlx5e_setup_tc_mqprio_dcb() function and
the mlx5e_safe_switch_params() function it calls have a copy of
'struct mlx5e_params' on the stack, and this structure is fairly
large.

Use dynamic allocation for the inner one.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c   | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 3973d86905e8..6b9267c19e00 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3002,32 +3002,37 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
 			     mlx5e_fp_preactivate preactivate,
 			     void *context, bool reset)
 {
-	struct mlx5e_channels new_chs = {};
+	struct mlx5e_channels *new_chs;
 	int err;
 
 	reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
 	if (!reset)
 		return mlx5e_switch_priv_params(priv, params, preactivate, context);
 
-	new_chs.params = *params;
+	new_chs = kzalloc(sizeof(*new_chs), GFP_KERNEL);
+	if (!new_chs)
+		return -ENOMEM;
+	new_chs->params = *params;
 
-	mlx5e_selq_prepare_params(&priv->selq, &new_chs.params);
+	mlx5e_selq_prepare_params(&priv->selq, &new_chs->params);
 
-	err = mlx5e_open_channels(priv, &new_chs);
+	err = mlx5e_open_channels(priv, new_chs);
 	if (err)
 		goto err_cancel_selq;
 
-	err = mlx5e_switch_priv_channels(priv, &new_chs, preactivate, context);
+	err = mlx5e_switch_priv_channels(priv, new_chs, preactivate, context);
 	if (err)
 		goto err_close;
 
+	kfree(new_chs);
 	return 0;
 
 err_close:
-	mlx5e_close_channels(&new_chs);
+	mlx5e_close_channels(new_chs);
 
 err_cancel_selq:
 	mlx5e_selq_cancel(&priv->selq);
+	kfree(new_chs);
 	return err;
 }
 
-- 
2.39.1


  reply	other threads:[~2023-02-08  0:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08  0:36 [pull request][net-next 00/15] mlx5 updates 2023-02-07 Saeed Mahameed
2023-02-08  0:36 ` Saeed Mahameed [this message]
2023-02-09  3:20   ` [net-next 01/15] mlx5: reduce stack usage in mlx5_setup_tc patchwork-bot+netdevbpf
2023-02-08  0:36 ` [net-next 02/15] net/mlx5: Remove redundant health work lock Saeed Mahameed
2023-02-08  0:37 ` [net-next 03/15] net/mlx5: fw reset: Skip device ID check if PCI link up failed Saeed Mahameed
2023-02-08  0:37 ` [net-next 04/15] net/mlx5e: Don't listen to remove flows event Saeed Mahameed
2023-02-08  0:37 ` [net-next 05/15] net/mlx5e: Remove redundant code for handling vlan actions Saeed Mahameed
2023-02-08  0:37 ` [net-next 06/15] net/mlx5: fs, Remove redundant vport_number assignment Saeed Mahameed
2023-02-08  0:37 ` [net-next 07/15] net/mlx5e: Remove incorrect debugfs_create_dir NULL check in hairpin Saeed Mahameed
2023-02-08  0:37 ` [net-next 08/15] net/mlx5e: Remove incorrect debugfs_create_dir NULL check in TLS Saeed Mahameed
2023-02-08  0:37 ` [net-next 09/15] net/mlx5: Fix memory leak in error flow of port set buffer Saeed Mahameed
2023-02-08  0:37 ` [net-next 10/15] net/mlx5: fs_core, Remove redundant variable err Saeed Mahameed
2023-02-08  0:37 ` [net-next 11/15] net/mlx5: fs, Remove redundant assignment of size Saeed Mahameed
2023-02-08  0:37 ` [net-next 12/15] net/mlx5: fw_tracer: Fix debug print Saeed Mahameed
2023-02-08  0:37 ` [net-next 13/15] net/mlx5: fw_tracer, allow 0 size string DBs Saeed Mahameed
2023-02-08  0:37 ` [net-next 14/15] net/mlx5: fw_tracer, Add support for strings DB update event Saeed Mahameed
2023-02-08  0:37 ` [net-next 15/15] net/mlx5: fw_tracer, Add support for unrecognized string Saeed Mahameed

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=20230208003712.68386-2-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).