[Devel] [PATCH RH9 19/30] net/vhost: Replace kmalloc with kvmalloc for order>=3
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Sep 28 21:49:10 MSK 2021
From: Oleg Babin <obabin at virtuozzo.com>
Currently we allocate 8 pages of memory in vhost_net_set_ubuf_info() function
and we do not need them to be physically contiguous, so it is feasible to
replace a call to kmalloc() with a call to kvmalloc().
UIO_MAXIOV = 1024
struct ubuf_info {
void (*callback)(struct ubuf_info *, bool zerocopy_success);
void *ctx;
unsigned long desc;
};
sizeof(struct ubuf_info) = 24
1024 * 24 / 4096 = 6, rounded up to 2^3 = 8 pages.
https://jira.sw.ru/browse/PSBM-81803
Signed-off-by: Oleg Babin <obabin at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
(cherry picked from vz7 commit 0cd748d35c10 ("net/vhost: Replace kmalloc with
kvmalloc for order>=3")
VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127797
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
(cherry picked from vz8 commit e1f1e1e8a44af104a6cb4cc2ab24a577f7c061f3)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
drivers/vhost/net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 6414bd5..913dac8 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -271,7 +271,7 @@ static void vhost_net_clear_ubuf_info(struct vhost_net *n)
int i;
for (i = 0; i < VHOST_NET_VQ_MAX; ++i) {
- kfree(n->vqs[i].ubuf_info);
+ kvfree(n->vqs[i].ubuf_info);
n->vqs[i].ubuf_info = NULL;
}
}
@@ -286,7 +286,7 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n)
if (!zcopy)
continue;
n->vqs[i].ubuf_info =
- kmalloc_array(UIO_MAXIOV,
+ kvmalloc_array(UIO_MAXIOV,
sizeof(*n->vqs[i].ubuf_info),
GFP_KERNEL);
if (!n->vqs[i].ubuf_info)
--
1.8.3.1
More information about the Devel
mailing list