hv_netvsc: Eliminate memory allocation in the send path
Subsystems (3)
cover hv_netvsc: Eliminate memory allocation in the send path
The network protocol used to communicate with the host is the remote ndis (rndis) protocol. We need to decorate each outgoing packet with a rndis header and additional rndis state (rndis per-packet state). To manage this state, we currently allocate memory in the transmit path. Eliminate this allocation by requesting additional head room in the skb.
K. Y. Srinivasan (2):
hyperv: Cleanup the test for freeing skb when we use sendbuf
mechanism
hyperv: Eliminate memory allocation in the packet send path
drivers/net/hyperv/hyperv_net.h | 3 +- drivers/net/hyperv/netvsc.c | 9 ++++- drivers/net/hyperv/netvsc_drv.c | 70 ++++++++++++++++++++++++++---------- drivers/net/hyperv/rndis_filter.c | 2 + 4 files changed, 61 insertions(+), 23 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/2 hv_netvsc: Cleanup the test for freeing skb when we use sendbuf mechanism
In preparation for embedding the rndis state and other packet state into the skb, cleanup the test for freeing the skb.
--- drivers/net/hyperv/netvsc.c | 1 + drivers/net/hyperv/netvsc_drv.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/hyperv/netvsc.c +1 -0
@@ -870,6 +870,7 @@ int netvsc_send(struct hv_device *device, (unsigned long )packet->send_completion_tid; packet->page_buf_cnt =0 ; + packet->send_completion_tid =0 ; packet->send_buf_index = section_index; packet->total_data_buflen += msd_len;
drivers/net/hyperv/netvsc_drv.c +1 -2
@@ -234,11 +234,10 @@ static void netvsc_xmit_completion(void *context)struct hv_netvsc_packet *packet = (struct hv_netvsc_packet *)context;struct sk_buff *skb = (struct sk_buff *) (unsigned long )packet->send_completion_tid; -u32 index = packet->send_buf_index;kfree (packet); -if (skb && (index ==NETVSC_INVALID_INDEX )) +if (skb)dev_kfree_skb_any (skb); }
Signature · 1 line
1.7.4.1
PATCH 2/2 hv_netvsc: Eliminate memory allocation in the packet send path
The network protocol used to communicate with the host is the remote ndis (rndis) protocol. We need to decorate each outgoing packet with a rndis header and additional rndis state (rndis per-packet state). To manage this state, we currently allocate memory in the transmit path. Eliminate this allocation by requesting additional head room in the skb.
--- drivers/net/hyperv/hyperv_net.h | 3 +- drivers/net/hyperv/netvsc.c | 10 ++++-- drivers/net/hyperv/netvsc_drv.c | 67 +++++++++++++++++++++++++++---------- drivers/net/hyperv/rndis_filter.c | 2 + 4 files changed, 60 insertions(+), 22 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -1
@@ -128,6 +128,7 @@ struct ndis_tcp_ip_checksum_info;struct hv_netvsc_packet {/* Bookkeeping stuff */ u32 status; +bool part_of_skb;struct hv_device *device;bool is_data_pkt;
@@ -150,7 +151,7 @@ struct hv_netvsc_packet {/* Points to the send/receive buffer where the ethernet frame is */ void *data;u32 page_buf_cnt; -struct hv_page_buffer page_buf[0 ]; +struct hv_page_buffer *page_buf; };struct netvsc_device_info {
drivers/net/hyperv/netvsc.c +7 -3
@@ -866,11 +866,15 @@ int netvsc_send(struct hv_device *device,netvsc_copy_to_send_buf (net_device, section_index, msd_len, packet); - skb = (struct sk_buff *) - (unsigned long )packet->send_completion_tid; +if (!packet->part_of_skb) { + skb = (struct sk_buff *) + (unsigned long ) + packet->send_completion_tid; + + packet->send_completion_tid =0 ; + } packet->page_buf_cnt =0 ; - packet->send_completion_tid =0 ; packet->send_buf_index = section_index; packet->total_data_buflen += msd_len;
drivers/net/hyperv/netvsc_drv.c +49 -18
126 lines not on this page · raw message
drivers/net/hyperv/rndis_filter.c +2 -0
@@ -210,6 +210,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, {int ret;struct hv_netvsc_packet *packet; +struct hv_page_buffer page_buf[2 ];/* Setup the packet to send it */ packet = &req->pkt;
@@ -217,6 +218,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, packet->is_data_pkt = false; packet->total_data_buflen = req->request_msg.msg_len; packet->page_buf_cnt =1 ; + packet->page_buf = page_buf; packet->page_buf[0 ].pfn =virt_to_phys (&req->request_msg) >>PAGE_SHIFT ;
Signature · 1 line
1.7.4.1
Re: [PATCH net-next 1/2] hv_netvsc: Cleanup the test for freeing skb when we use sendbuf mechanism
In reply to K. Y. SrinivasanQuoted 3 lines · K. Y. Srinivasan
In preparation for embedding the rndis state and other packet state into the skb, cleanup the test for freeing the skb.
So there is no behavior change in applying this patch?
regards,
dan carpenter
RE: [PATCH net-next 1/2] hv_netvsc: Cleanup the test for freeing skb when we use sendbuf mechanism
Quoted 12 lines
-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Monday, March 30, 2015 2:03 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next 1/2]hv_netvsc: Cleanup the test for freeing skb when we use sendbuf mechanism
Quoted 6 lines
Quoted 3 lines · K. Y. Srinivasan
In preparation for embedding the rndis state and other packet state into the skb, cleanup the test for freeing the skb.
So there is no behavior change in applying this patch?
No. When we send the packet through sendbuf, we will free up the skb after we copy the data. The test used in the send path can also be used in the send complete path. That is what I have done.
K. Y
Quoted 3 lines
regards,
dan carpenter
David Miller
maintainerFrom: "K. Y. Srinivasan" <[email protected]>
Date: Sun, 29 Mar 2015 21:07:58 -0700
Quoted 5 lines
The network protocol used to communicate with the host is the remote ndis (rndis) protocol. We need to decorate each outgoing packet with a rndis header and additional rndis state (rndis per-packet state). To manage this state, we currently allocate memory in the transmit path. Eliminate this allocation by requesting additional head room in the skb.
Series applied, thanks.