mlx5: avoid frame overflow warning
Subsystems (2)
PATCH 1/1 mlx5: avoid frame overflow warning
From: Arnd Bergmann <[email protected]>
Building mlx5 on s390 shows a rather high stack usage that can exceed the warning limit when that is set to a lower but still reasonable value:
drivers/infiniband/hw/mlx5/wr.c:1051:5: error: stack frame size (1328) exceeds limit (1280) in 'mlx5_ib_post_send' [-Werror,-Wframe-larger-than]
The problem here is 'struct ib_reg_wr' on the stack of handle_reg_mr_integrity(), which gets inlined into mlx5_ib_post_send() along with a number of smaller functions.
Keeping the inner function out of line like gcc does avoids the warning and reduces the total stack usage in other functions called from mlx5_ib_post_send(), though handle_reg_mr_integrity() itself still has the same problem as before.
---
Dynamically allocating ib_reg_wr would be another option, actually reducing the stack usage but adding a little bit of complexity from error handling.
--- drivers/infiniband/hw/mlx5/wr.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx5/wr.c +9 -7
@@ -840,13 +840,15 @@ static int handle_psv(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,return err; } -static int handle_reg_mr_integrity (struct mlx5_ib_dev *dev, -struct mlx5_ib_qp *qp, -const struct ib_send_wr *wr, -struct mlx5_wqe_ctrl_seg **ctrl,void **seg, -int *size,void **cur_edge, -unsigned int *idx,int nreq,u8 fence, -u8 next_fence) +static noinline_for_stack int handle_reg_mr_integrity(struct mlx5_ib_dev *dev, +struct mlx5_ib_qp *qp, +const struct ib_send_wr *wr, +struct mlx5_wqe_ctrl_seg **ctrl, +void **seg, +int *size,void **cur_edge, +unsigned int *idx,int nreq, +u8 fence, +u8 next_fence) {struct mlx5_ib_mr *mr;struct mlx5_ib_mr *pi_mr;
Signature · 1 line
2.39.5
Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Building mlx5 on s390 shows a rather high stack usage that can exceed the warning limit when that is set to a lower but still reasonable value:
drivers/infiniband/hw/mlx5/wr.c:1051:5: error: stack frame size (1328) exceeds limit (1280) in 'mlx5_ib_post_send' [-Werror,-Wframe-larger-than]
Quoted 8 lines
The problem here is 'struct
ib_reg_wr' on the stack ofhandle_reg_mr_integrity(), which gets inlined intomlx5_ib_post_send()along with a number of smaller functions.Keeping the inner function out of line like gcc does avoids the warning and reduces the total stack usage in other functions called from
mlx5_ib_post_send(), thoughhandle_reg_mr_integrity()itself still has the same problem as before.
IMO, it is just a workaround to this problem. To fix this problem, the function set_reg_wr should be rewritten.
Zhu Yanjun
Quoted 37 lines
Signed-off-by Arnd Bergmann <[email protected]>---
Dynamically allocatingib_reg_wrwould be another option, actually reducing the stack usage but adding a little bit of complexity from error handling.--- drivers/infiniband/hw/mlx5/wr.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/infiniband/hw/mlx5/wr.c +9
-7@@ -840,13 +840,15 @@ static int handle_psv(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,return err; } -static int handle_reg_mr_integrity (struct mlx5_ib_dev *dev, -struct mlx5_ib_qp *qp, -const struct ib_send_wr *wr, -struct mlx5_wqe_ctrl_seg **ctrl,void **seg, -int *size,void **cur_edge, -unsigned int *idx,int nreq,u8 fence, -u8 next_fence) +static noinline_for_stack int handle_reg_mr_integrity(struct mlx5_ib_dev *dev, +struct mlx5_ib_qp *qp, +const struct ib_send_wr *wr, +struct mlx5_wqe_ctrl_seg **ctrl, +void **seg, +int *size,void **cur_edge, +unsigned int *idx,int nreq, +u8 fence, +u8 next_fence) {struct mlx5_ib_mr *mr;struct mlx5_ib_mr *pi_mr;
Leon Romanovsky
AppliedQuoted 10 lines · Arnd Bergmann
Building mlx5 on s390 shows a rather high stack usage that can exceed the warning limit when that is set to a lower but still reasonable value:
drivers/infiniband/hw/mlx5/wr.c:1051:5: error: stack frame size (1328) exceeds limit (1280) in 'mlx5_ib_post_send' [-Werror,-Wframe-larger-than]The problem here is 'struct
ib_reg_wr' on the stack ofhandle_reg_mr_integrity(), which gets inlined intomlx5_ib_post_send()along with a number of smaller functions.[...]
Applied, thanks!
[1/1] mlx5: avoid frame overflow warning
https://git.kernel.org/rdma/rdma/c/f5ad2ead846e3a
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>