Re: [PATCH] net/mlx5: reduce stack usage in qp_read_field

From: Leon Romanovsky
Date: Sun May 03 2020 - 01:30:14 EST


On Thu, Apr 30, 2020 at 04:37:14PM +0200, Arnd Bergmann wrote:
> On Thu, Apr 30, 2020 at 7:22 AM Leon Romanovsky <leon@xxxxxxxxxx> wrote:
> > On Tue, Apr 28, 2020 at 11:23:47PM +0200, Arnd Bergmann wrote:
> > > Moving the mlx5_ifc_query_qp_out_bits structure on the stack was a bit
> > > excessive and now causes the compiler to complain on 32-bit architectures:
> > >
> > > drivers/net/ethernet/mellanox/mlx5/core/debugfs.c: In function 'qp_read_field':
> > > drivers/net/ethernet/mellanox/mlx5/core/debugfs.c:274:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> > >
> > > Revert the previous patch partially to use dynamically allocation as
> > > the code did before. Unfortunately there is no good error handling
> > > in case the allocation fails.
> > >
> > > Fixes: 57a6c5e992f5 ("net/mlx5: Replace hand written QP context struct with automatic getters")
> > > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> > > ---
> > > drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 12 +++++++++---
> > > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > Thanks Arnd, I'll pick it to mlx5-next.
> >
> > I was under impression that the frame size was increased a long
> > time ago. Is this 1K limit still effective for all archs?
> > Or is it is 32-bit leftover?
>
> I got the output on a 32-bit build, but that doesn't make the code
> right on 64-bit.
>
> While warning limit is generally 1024 bytes for 32-bit architectures,
> and 2048 bytes fro 64-bit architectures, we should probably
> reduce the latter to something like 1280 bytes and fix up the
> warnings that introduces.

It a chicken and an egg problem, I tried to use default frame size, but
the output of my kernel build was constantly flooded with those warnings
and made hard to spot real issues in the code I developed.

Thanks

>
> Generally speaking, I'd say a function using more than a few hundred
> bytes tends to be a bad idea, but we can't warn about those without
> also warning about the handful of cases that do it for a good reason
> and using close to 1024 bytes on 32 bit systems or a little more on
> 64-bit systems, in places that are known not to have deep call chains.
>
> Arnd