[vz7] net/vhost: Replace kmalloc with kvmalloc for order>=3

Submitted by Oleg Babin on Feb. 27, 2018, 8:12 a.m.

Details

Message ID 1519719159-67740-1-git-send-email-obabin@virtuozzo.com
State New
Series "net/vhost: Replace kmalloc with kvmalloc for order>=3"
Headers show

Commit Message

Oleg Babin Feb. 27, 2018, 8:12 a.m.
Currently we allocate more than eight 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().

https://jira.sw.ru/browse/PSBM-81803
Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
---
 drivers/vhost/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 1076a46..900463b 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -165,7 +165,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;
 	}
 }
@@ -179,8 +179,8 @@  int vhost_net_set_ubuf_info(struct vhost_net *n)
 		zcopy = vhost_net_zcopy_mask & (0x1 << i);
 		if (!zcopy)
 			continue;
-		n->vqs[i].ubuf_info = kmalloc(sizeof(*n->vqs[i].ubuf_info) *
-					      UIO_MAXIOV, GFP_KERNEL);
+		n->vqs[i].ubuf_info = kvmalloc(sizeof(*n->vqs[i].ubuf_info) *
+					       UIO_MAXIOV, GFP_KERNEL);
 		if  (!n->vqs[i].ubuf_info)
 			goto err;
 	}

Comments

Andrey Ryabinin Feb. 27, 2018, 10:32 a.m.
On 02/27/2018 11:12 AM, Oleg Babin wrote:
> Currently we allocate more than eight 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().
> 
> https://jira.sw.ru/browse/PSBM-81803
> Signed-off-by: Oleg Babin <obabin@virtuozzo.com>

Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>