[PATCH RESEND] nvmet-tcp: get rid of a high-order allocation
Sagi Grimberg
sagi at grimberg.me
Fri Jan 31 04:05:09 PST 2025
Allocating the queue commands array leads to a high order
allocation.
The current size of nvmet_tcp_cmd is 704 bytes. Allocating
128 of those (default queue depth) means that we are allocating
an array of 90K bytes. There is no reason why this will be
a single contiguous allocation. Change the allocation to be
kvcalloc instead.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/target/tcp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 7c51c2a8c109..79b888b10c2b 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1516,7 +1516,7 @@ static int nvmet_tcp_alloc_cmds(struct nvmet_tcp_queue *queue)
struct nvmet_tcp_cmd *cmds;
int i, ret = -EINVAL, nr_cmds = queue->nr_cmds;
- cmds = kcalloc(nr_cmds, sizeof(struct nvmet_tcp_cmd), GFP_KERNEL);
+ cmds = vcalloc(nr_cmds, sizeof(struct nvmet_tcp_cmd));
if (!cmds)
goto out;
@@ -1532,7 +1532,7 @@ static int nvmet_tcp_alloc_cmds(struct nvmet_tcp_queue *queue)
out_free:
while (--i >= 0)
nvmet_tcp_free_cmd(cmds + i);
- kfree(cmds);
+ vfree(cmds);
out:
return ret;
}
@@ -1546,7 +1546,7 @@ static void nvmet_tcp_free_cmds(struct nvmet_tcp_queue *queue)
nvmet_tcp_free_cmd(cmds + i);
nvmet_tcp_free_cmd(&queue->connect);
- kfree(cmds);
+ vfree(cmds);
}
static void nvmet_tcp_restore_socket_callbacks(struct nvmet_tcp_queue *queue)
--
2.43.0
More information about the Linux-nvme
mailing list