[Devel] [PATCH RHEL8 COMMIT] net/vhost: Replace kmalloc with kvmalloc for order>=3
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 24 18:31:55 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.32
------>
commit f7c5f9e4e109adfb4f61def8e1095644d33ef4fd
Author: Oleg Babin <obabin at virtuozzo.com>
Date: Mon May 24 18:31:55 2021 +0300
net/vhost: Replace kmalloc with kvmalloc for order>=3
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>
---
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 267877d8273b..07a2d3482d9d 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -272,7 +272,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;
}
}
@@ -287,7 +287,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)
More information about the Devel
mailing list