diff mbox series

mlx5: work around high stack usage with gcc

Message ID 20200104215156.689245-1-arnd@arndb.de
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series mlx5: work around high stack usage with gcc | expand

Commit Message

Arnd Bergmann Jan. 4, 2020, 9:51 p.m. UTC
In some configurations, gcc tries too hard to optimize this code:

drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: In function 'mlx5e_grp_sw_update_stats':
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c:302:1: error: the frame size of 1336 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

As was stated in the bug report, the reason is that gcc runs into a corner
case in the register allocator that is rather hard to fix in a good way.

As there is an easy way to work around it, just add a comment and the
barrier that stops gcc from trying to overoptimize the function.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92657
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Miller Jan. 6, 2020, 9:34 p.m. UTC | #1
From: Arnd Bergmann <arnd@arndb.de>
Date: Sat,  4 Jan 2020 22:51:44 +0100

> In some configurations, gcc tries too hard to optimize this code:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: In function 'mlx5e_grp_sw_update_stats':
> drivers/net/ethernet/mellanox/mlx5/core/en_stats.c:302:1: error: the frame size of 1336 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> 
> As was stated in the bug report, the reason is that gcc runs into a corner
> case in the register allocator that is rather hard to fix in a good way.
> 
> As there is an easy way to work around it, just add a comment and the
> barrier that stops gcc from trying to overoptimize the function.
> 
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92657
> Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Saeed, please take this.

Thank you.
Saeed Mahameed Jan. 6, 2020, 9:59 p.m. UTC | #2
On Mon, 2020-01-06 at 13:34 -0800, David Miller wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Sat,  4 Jan 2020 22:51:44 +0100
> 
> > In some configurations, gcc tries too hard to optimize this code:
> > 
> > drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: In function
> 'mlx5e_grp_sw_update_stats':
> > drivers/net/ethernet/mellanox/mlx5/core/en_stats.c:302:1: error:
> the frame size of 1336 bytes is larger than 1024 bytes [-
> Werror=frame-larger-than=]
> > 
> > As was stated in the bug report, the reason is that gcc runs into a
> corner
> > case in the register allocator that is rather hard to fix in a good
> way.
> > 
> > As there is an easy way to work around it, just add a comment and
> the
> > barrier that stops gcc from trying to overoptimize the function.
> > 
> > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92657
> > Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Saeed, please take this.
> 
> Thank you.
> 

Applied to net-next-mlx5

will submit to net-next later today.

Thanks !
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index 9f09253f9f46..a05158472ed1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -297,6 +297,9 @@  static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
 			s->tx_tls_drop_bypass_req   += sq_stats->tls_drop_bypass_req;
 #endif
 			s->tx_cqes		+= sq_stats->cqes;
+
+			/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92657 */
+			barrier();
 		}
 	}
 }