From: Oleg Babin <[email protected]>

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 <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>
(cherry picked from commit 0cd748d35c100b1bc6f9e7fffa44a7d0f70a1728)

VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127797

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
---
 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)
-- 
2.28.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to