Commit ca11b798 authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

net/mlx5e: Convert large order kzalloc allocations to kvzalloc

Replace calls to kzalloc_node with kvzalloc_node, as it fallsback
to lower-order pages if the higher-order trials fail.
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent bc5a7ccd
...@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, ...@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
{ {
int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info), rq->mpwqe.info = kvzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
GFP_KERNEL, cpu_to_node(c->cpu)); GFP_KERNEL, cpu_to_node(c->cpu));
if (!rq->mpwqe.info) if (!rq->mpwqe.info)
return -ENOMEM; return -ENOMEM;
...@@ -670,7 +670,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, ...@@ -670,7 +670,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
err_free: err_free:
switch (rq->wq_type) { switch (rq->wq_type) {
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
kfree(rq->mpwqe.info); kvfree(rq->mpwqe.info);
mlx5_core_destroy_mkey(mdev, &rq->umr_mkey); mlx5_core_destroy_mkey(mdev, &rq->umr_mkey);
break; break;
default: /* MLX5_WQ_TYPE_CYCLIC */ default: /* MLX5_WQ_TYPE_CYCLIC */
...@@ -702,7 +702,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq) ...@@ -702,7 +702,7 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq)
switch (rq->wq_type) { switch (rq->wq_type) {
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
kfree(rq->mpwqe.info); kvfree(rq->mpwqe.info);
mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey); mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey);
break; break;
default: /* MLX5_WQ_TYPE_CYCLIC */ default: /* MLX5_WQ_TYPE_CYCLIC */
...@@ -965,14 +965,14 @@ static void mlx5e_close_rq(struct mlx5e_rq *rq) ...@@ -965,14 +965,14 @@ static void mlx5e_close_rq(struct mlx5e_rq *rq)
static void mlx5e_free_xdpsq_db(struct mlx5e_xdpsq *sq) static void mlx5e_free_xdpsq_db(struct mlx5e_xdpsq *sq)
{ {
kfree(sq->db.di); kvfree(sq->db.di);
} }
static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa) static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
{ {
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di), sq->db.di = kvzalloc_node(sizeof(*sq->db.di) * wq_sz,
GFP_KERNEL, numa); GFP_KERNEL, numa);
if (!sq->db.di) { if (!sq->db.di) {
mlx5e_free_xdpsq_db(sq); mlx5e_free_xdpsq_db(sq);
...@@ -1024,14 +1024,14 @@ static void mlx5e_free_xdpsq(struct mlx5e_xdpsq *sq) ...@@ -1024,14 +1024,14 @@ static void mlx5e_free_xdpsq(struct mlx5e_xdpsq *sq)
static void mlx5e_free_icosq_db(struct mlx5e_icosq *sq) static void mlx5e_free_icosq_db(struct mlx5e_icosq *sq)
{ {
kfree(sq->db.ico_wqe); kvfree(sq->db.ico_wqe);
} }
static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa) static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
{ {
u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe), sq->db.ico_wqe = kvzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
GFP_KERNEL, numa); GFP_KERNEL, numa);
if (!sq->db.ico_wqe) if (!sq->db.ico_wqe)
return -ENOMEM; return -ENOMEM;
...@@ -1077,8 +1077,8 @@ static void mlx5e_free_icosq(struct mlx5e_icosq *sq) ...@@ -1077,8 +1077,8 @@ static void mlx5e_free_icosq(struct mlx5e_icosq *sq)
static void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq) static void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq)
{ {
kfree(sq->db.wqe_info); kvfree(sq->db.wqe_info);
kfree(sq->db.dma_fifo); kvfree(sq->db.dma_fifo);
} }
static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa) static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
...@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa) ...@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo), sq->db.dma_fifo = kvzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
GFP_KERNEL, numa); GFP_KERNEL, numa);
sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info), sq->db.wqe_info = kvzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
GFP_KERNEL, numa); GFP_KERNEL, numa);
if (!sq->db.dma_fifo || !sq->db.wqe_info) { if (!sq->db.dma_fifo || !sq->db.wqe_info) {
mlx5e_free_txqsq_db(sq); mlx5e_free_txqsq_db(sq);
...@@ -1893,7 +1893,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, ...@@ -1893,7 +1893,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
int err; int err;
int eqn; int eqn;
c = kzalloc_node(sizeof(*c), GFP_KERNEL, cpu_to_node(cpu)); c = kvzalloc_node(sizeof(*c), GFP_KERNEL, cpu_to_node(cpu));
if (!c) if (!c)
return -ENOMEM; return -ENOMEM;
...@@ -1979,7 +1979,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, ...@@ -1979,7 +1979,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
err_napi_del: err_napi_del:
netif_napi_del(&c->napi); netif_napi_del(&c->napi);
kfree(c); kvfree(c);
return err; return err;
} }
...@@ -2018,7 +2018,7 @@ static void mlx5e_close_channel(struct mlx5e_channel *c) ...@@ -2018,7 +2018,7 @@ static void mlx5e_close_channel(struct mlx5e_channel *c)
mlx5e_close_cq(&c->icosq.cq); mlx5e_close_cq(&c->icosq.cq);
netif_napi_del(&c->napi); netif_napi_del(&c->napi);
kfree(c); kvfree(c);
} }
#define DEFAULT_FRAG_SIZE (2048) #define DEFAULT_FRAG_SIZE (2048)
...@@ -2276,7 +2276,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv, ...@@ -2276,7 +2276,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
chs->num = chs->params.num_channels; chs->num = chs->params.num_channels;
chs->c = kcalloc(chs->num, sizeof(struct mlx5e_channel *), GFP_KERNEL); chs->c = kcalloc(chs->num, sizeof(struct mlx5e_channel *), GFP_KERNEL);
cparam = kzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL); cparam = kvzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL);
if (!chs->c || !cparam) if (!chs->c || !cparam)
goto err_free; goto err_free;
...@@ -2287,7 +2287,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv, ...@@ -2287,7 +2287,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
goto err_close_channels; goto err_close_channels;
} }
kfree(cparam); kvfree(cparam);
return 0; return 0;
err_close_channels: err_close_channels:
...@@ -2296,7 +2296,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv, ...@@ -2296,7 +2296,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
err_free: err_free:
kfree(chs->c); kfree(chs->c);
kfree(cparam); kvfree(cparam);
chs->num = 0; chs->num = 0;
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment