Skip to contentSkip to conversation

hyperv: Increase the buffer length for netvsc_channel_cb()

PATCH Superseded Haiyang Zhang 2 participants 3 messages Aug 13, 2014 – Aug 14, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Haiyang Zhang

author maintainer
#0 lore raw

PATCH v2 1/1 hyperv: Increase the buffer length for netvsc_channel_cb()

When the buffer is too small for a packet from VMBus, a bigger buffer will be allocated in netvsc_channel_cb() and retry reading the packet from VMBus. Increasing this buffer size will reduce the retry overhead.

---
 drivers/net/hyperv/hyperv_net.h |    2 +-
 drivers/net/hyperv/netvsc.c     |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/hyperv/hyperv_net.h +1 -1
index d5e07de..b14a0ef 100644
@@ -591,7 +591,7 @@ struct nvsp_message {
 
 #define NETVSC_RECEIVE_BUFFER_ID		0xcafe
 
-#define NETVSC_PACKET_SIZE                      2048
+#define NETVSC_PACKET_SIZE                      4096
 
 #define VRSS_SEND_TAB_SIZE 16
 
drivers/net/hyperv/netvsc.c +3 -3
index 66979cf..45899f2 100644
@@ -38,7 +38,7 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
 	struct netvsc_device *net_device;
 	struct net_device *ndev = hv_get_drvdata(device);
 
-	net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
+	net_device = vzalloc(sizeof(*net_device));
 	if (!net_device)
 		return NULL;
 
@@ -551,7 +551,7 @@ int netvsc_device_remove(struct hv_device *device)
 	if (net_device->sub_cb_buf)
 		vfree(net_device->sub_cb_buf);
 
-	kfree(net_device);
+	vfree(net_device);
 	return 0;
 }
 
@@ -1093,7 +1093,7 @@ close:
 	vmbus_close(device->channel);
 
 cleanup:
-	kfree(net_device);
+	vfree(net_device);
 
 	return ret;
 }
Signature · 1 line
1.7.1
#1 lore raw

From: Haiyang Zhang <[email protected]>
Date: Wed, 13 Aug 2014 18:03:44 +0000

Quoted 6 lines

When the buffer is too small for a packet from VMBus, a bigger buffer will be allocated in netvsc_channel_cb() and retry reading the packet from VMBus. Increasing this buffer size will reduce the retry overhead.

...

drivers/net/hyperv/netvsc.c static struct netvsc_device *alloc_net_device(struct hv_device *device) · line 41

Quoted 2 lines
drivers/net/hyperv/netvsc.c +1 -1
-	net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
+	net_device = vzalloc(sizeof(*net_device));

This isn't what I suggested that you do.

I said that the buffer inside of netvsc_device should be made an indirect pointer and thus allocated seperately.

Thus you're still kzalloc() net_device, but net_device->cb_buffer becomes "unsigned char *" and another allocation is made for it.

author maintainer
#2 lore raw
Quoted 29 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Thursday, August 14, 2014 5:29 PM
To: Haiyang Zhang
Cc: [email protected]; KY Srinivasan; [email protected]; [email protected]; [email protected]; driverdev- [email protected]
Subject: Re: [PATCH net-next,v2] hyperv: Increase the buffer length for netvsc_channel_cb()

From: Haiyang Zhang <[email protected]>
Date: Wed, 13 Aug 2014 18:03:44 +0000

Quoted 1 line

When the buffer is too small for a packet from VMBus, a bigger buffer

will be

Quoted 1 line

allocated in netvsc_channel_cb() and retry reading the packet from

VMBus.

Quoted 4 lines

Increasing this buffer size will reduce the retry overhead.

...

drivers/net/hyperv/netvsc.c static struct netvsc_device *alloc_net_device(struct hv_device *device) · line 41

Quoted 2 lines
drivers/net/hyperv/netvsc.c +1 -1
-	net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
+	net_device = vzalloc(sizeof(*net_device));

This isn't what I suggested that you do.

Quoted 5 lines

I said that the buffer inside of netvsc_device should be made an indirect pointer and thus allocated seperately.

Thus you're still kzalloc() net_device, but net_device->cb_buffer becomes "unsigned char *" and another allocation is made for it.

I will change the patch to this way.
Thanks,

- Haiyang