netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hinic: reduce rss_init stack usage
@ 2019-06-28 10:31 Arnd Bergmann
  2019-06-28 16:32 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-06-28 10:31 UTC (permalink / raw)
  To: Aviad Krawczyk, David S. Miller
  Cc: Arnd Bergmann, Xue Chaojing, Jesse Brandeburg, Zhao Chen,
	Eric Dumazet, dann frazier, netdev, linux-kernel

On 32-bit architectures, putting an array of 256 u32 values on the
stack uses more space than the warning limit:

drivers/net/ethernet/huawei/hinic/hinic_main.c: In function 'hinic_rss_init':
drivers/net/ethernet/huawei/hinic/hinic_main.c:286:1: error: the frame size of 1068 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

I considered changing the code to use u8 values here, since that's
all the hardware supports, but dynamically allocating the array is
a more isolated fix here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 .../net/ethernet/huawei/hinic/hinic_main.c    | 20 ++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
index 1b917543feac..ceb0e247f52d 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
@@ -256,37 +256,43 @@ static int hinic_configure_max_qnum(struct hinic_dev *nic_dev)
 
 static int hinic_rss_init(struct hinic_dev *nic_dev)
 {
-	u32 indir_tbl[HINIC_RSS_INDIR_SIZE] = { 0 };
 	u8 default_rss_key[HINIC_RSS_KEY_SIZE];
 	u8 tmpl_idx = nic_dev->rss_tmpl_idx;
+	u32 *indir_tbl;
 	int err, i;
 
+	indir_tbl = kcalloc(HINIC_RSS_INDIR_SIZE, sizeof(u32), GFP_KERNEL);
+	if (!indir_tbl)
+		return -ENOMEM;
+
 	netdev_rss_key_fill(default_rss_key, sizeof(default_rss_key));
 	for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
 		indir_tbl[i] = ethtool_rxfh_indir_default(i, nic_dev->num_rss);
 
 	err = hinic_rss_set_template_tbl(nic_dev, tmpl_idx, default_rss_key);
 	if (err)
-		return err;
+		goto out;
 
 	err = hinic_rss_set_indir_tbl(nic_dev, tmpl_idx, indir_tbl);
 	if (err)
-		return err;
+		goto out;
 
 	err = hinic_set_rss_type(nic_dev, tmpl_idx, nic_dev->rss_type);
 	if (err)
-		return err;
+		goto out;
 
 	err = hinic_rss_set_hash_engine(nic_dev, tmpl_idx,
 					nic_dev->rss_hash_engine);
 	if (err)
-		return err;
+		goto out;
 
 	err = hinic_rss_cfg(nic_dev, 1, tmpl_idx);
 	if (err)
-		return err;
+		goto out;
 
-	return 0;
+out:
+	kfree(indir_tbl);
+	return err;
 }
 
 static void hinic_rss_deinit(struct hinic_dev *nic_dev)
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hinic: reduce rss_init stack usage
  2019-06-28 10:31 [PATCH] hinic: reduce rss_init stack usage Arnd Bergmann
@ 2019-06-28 16:32 ` David Miller
  2019-07-01 15:03   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-06-28 16:32 UTC (permalink / raw)
  To: arnd
  Cc: aviad.krawczyk, xuechaojing, jesse.brandeburg, zhaochen6,
	edumazet, dann.frazier, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 28 Jun 2019 12:31:44 +0200

> On 32-bit architectures, putting an array of 256 u32 values on the
> stack uses more space than the warning limit:
> 
> drivers/net/ethernet/huawei/hinic/hinic_main.c: In function 'hinic_rss_init':
> drivers/net/ethernet/huawei/hinic/hinic_main.c:286:1: error: the frame size of 1068 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> 
> I considered changing the code to use u8 values here, since that's
> all the hardware supports, but dynamically allocating the array is
> a more isolated fix here.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to net-next.

Arnd, please make it clear what tree you are targetting in the
future.  Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hinic: reduce rss_init stack usage
  2019-06-28 16:32 ` David Miller
@ 2019-07-01 15:03   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-07-01 15:03 UTC (permalink / raw)
  To: David Miller
  Cc: Aviad Krawczyk, xuechaojing, Jesse Brandeburg, zhaochen6,
	Eric Dumazet, Dann Frazier, Networking,
	Linux Kernel Mailing List

On Fri, Jun 28, 2019 at 6:32 PM David Miller <davem@davemloft.net> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Fri, 28 Jun 2019 12:31:44 +0200
>
> > On 32-bit architectures, putting an array of 256 u32 values on the
> > stack uses more space than the warning limit:
> >
> > drivers/net/ethernet/huawei/hinic/hinic_main.c: In function 'hinic_rss_init':
> > drivers/net/ethernet/huawei/hinic/hinic_main.c:286:1: error: the frame size of 1068 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> >
> > I considered changing the code to use u8 values here, since that's
> > all the hardware supports, but dynamically allocating the array is
> > a more isolated fix here.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Applied to net-next.

Thanks

> Arnd, please make it clear what tree you are targetting in the
> future.

Sorry about missing this again. I usually remember but sometimes
one slips through when I send a lot of patches for different subsystems
at once.

      Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-01 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28 10:31 [PATCH] hinic: reduce rss_init stack usage Arnd Bergmann
2019-06-28 16:32 ` David Miller
2019-07-01 15:03   ` Arnd Bergmann

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).