net/mlx5: E-Switch, let esw work callers choose GFP flags

mlx5_esw_add_work() always allocates the queued work item with
GFP_ATOMIC. That is required for the E-Switch functions-change notifier,
but not every caller of this helper will run from atomic context.

Pass an allocation flag to mlx5_esw_add_work() and keep the notifier
caller using GFP_ATOMIC. This allows sleepable callers to use GFP_KERNEL
instead of unnecessarily relying on atomic reserves.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260503202726.266415-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Mark Bloch 2026-05-03 23:27:21 +03:00 committed by Jakub Kicinski
parent b501400fa6
commit 386ef557f6

View File

@ -3736,11 +3736,12 @@ static void esw_wq_handler(struct work_struct *work)
}
static int mlx5_esw_add_work(struct mlx5_eswitch *esw,
void (*func)(struct mlx5_eswitch *esw))
void (*func)(struct mlx5_eswitch *esw),
gfp_t gfp)
{
struct mlx5_host_work *host_work;
host_work = kzalloc_obj(*host_work, GFP_ATOMIC);
host_work = kzalloc_obj(*host_work, gfp);
if (!host_work)
return -ENOMEM;
@ -3764,7 +3765,8 @@ int mlx5_esw_funcs_changed_handler(struct notifier_block *nb,
esw_funcs = mlx5_nb_cof(nb, struct mlx5_esw_functions, nb);
esw = container_of(esw_funcs, struct mlx5_eswitch, esw_funcs);
ret = mlx5_esw_add_work(esw, esw_vfs_changed_event_handler);
ret = mlx5_esw_add_work(esw, esw_vfs_changed_event_handler,
GFP_ATOMIC);
if (ret)
return NOTIFY_DONE;