Skip to content

Commit b26852d

Browse files
arndbrleon
authored andcommitted
RDMA/mlx5: reduce stack usage in mlx5_ib_ufile_hw_cleanup
This function has an array of eight mlx5_async_cmd structures, which often fits on the stack, but depending on the configuration can end up blowing the stack frame warning limit: drivers/infiniband/hw/mlx5/devx.c:2670:6: error: stack frame size (1392) exceeds limit (1280) in 'mlx5_ib_ufile_hw_cleanup' [-Werror,-Wframe-larger-than] Change this to a dynamic allocation instead. While a kmalloc() can theoretically fail, a GFP_KERNEL allocation under a page will block until memory has been freed up, so in the worst case, this only adds extra time in an already constrained environment. Fixes: 7c891a4 ("RDMA/mlx5: Add implementation for ufile_hw_cleanup device operation") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://patch.msgid.link/20250610092846.2642535-1-arnd@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 19272b3 commit b26852d

File tree

1 file changed

+7
-1
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+7
-1
lines changed

drivers/infiniband/hw/mlx5/devx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ static void devx_wait_async_destroy(struct mlx5_async_cmd *cmd)
26692669

26702670
void mlx5_ib_ufile_hw_cleanup(struct ib_uverbs_file *ufile)
26712671
{
2672-
struct mlx5_async_cmd async_cmd[MAX_ASYNC_CMDS];
2672+
struct mlx5_async_cmd *async_cmd;
26732673
struct ib_ucontext *ucontext = ufile->ucontext;
26742674
struct ib_device *device = ucontext->device;
26752675
struct mlx5_ib_dev *dev = to_mdev(device);
@@ -2678,6 +2678,10 @@ void mlx5_ib_ufile_hw_cleanup(struct ib_uverbs_file *ufile)
26782678
int head = 0;
26792679
int tail = 0;
26802680

2681+
async_cmd = kcalloc(MAX_ASYNC_CMDS, sizeof(*async_cmd), GFP_KERNEL);
2682+
if (!async_cmd)
2683+
return;
2684+
26812685
list_for_each_entry(uobject, &ufile->uobjects, list) {
26822686
WARN_ON(uverbs_try_lock_object(uobject, UVERBS_LOOKUP_WRITE));
26832687

@@ -2713,6 +2717,8 @@ void mlx5_ib_ufile_hw_cleanup(struct ib_uverbs_file *ufile)
27132717
devx_wait_async_destroy(&async_cmd[head % MAX_ASYNC_CMDS]);
27142718
head++;
27152719
}
2720+
2721+
kfree(async_cmd);
27162722
}
27172723

27182724
static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,

0 commit comments

Comments
 (0)