* [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag()
@ 2013-11-01 6:07 Jason Wang
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jason Wang @ 2013-11-01 6:07 UTC (permalink / raw)
To: davem, edumazet, linux-kernel, netdev, rusty, mst, mwdalton,
virtualization
Cc: kmindg
Sometimes we need to coalesce the rx frags to avoid frag list. One example is
virtio-net driver which tries to use small frags for both MTU sized packet and
GSO packet. So this patch introduce skb_coalesce_rx_frag() to do this.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michael Dalton <mwdalton@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V2:
- remove the skb_frag_unref() and let the called to put the page reference
Changes from V1:
- remove the useless off parameter.
---
include/linux/skbuff.h | 3 +++
net/core/skbuff.c | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2c15497..fffaeaf 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1372,6 +1372,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
int size, unsigned int truesize);
+void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
+ unsigned int truesize);
+
#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb))
#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 0ab32fa..a729b97 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -476,6 +476,18 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
}
EXPORT_SYMBOL(skb_add_rx_frag);
+void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
+ unsigned int truesize)
+{
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+ skb_frag_size_add(frag, size);
+ skb->len += size;
+ skb->data_len += size;
+ skb->truesize += truesize;
+}
+EXPORT_SYMBOL(skb_coalesce_rx_frag);
+
static void skb_drop_list(struct sk_buff **listp)
{
kfree_skb_list(*listp);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx
2013-11-01 6:07 [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Jason Wang
@ 2013-11-01 6:07 ` Jason Wang
2013-11-01 9:47 ` Eric Dumazet
2013-11-05 1:04 ` David Miller
2013-11-01 9:45 ` [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Eric Dumazet
2013-11-05 1:04 ` David Miller
2 siblings, 2 replies; 6+ messages in thread
From: Jason Wang @ 2013-11-01 6:07 UTC (permalink / raw)
To: davem, edumazet, linux-kernel, netdev, rusty, mst, mwdalton,
virtualization
Cc: kmindg
Commit 2613af0ed18a11d5c566a81f9a6510b73180660a (virtio_net: migrate mergeable
rx buffers to page frag allocators) try to increase the payload/truesize for
MTU-sized traffic. But this will introduce the extra overhead for GSO packets
received because of the frag list. This commit tries to reduce this issue by
coalesce the possible rx frags when possible during rx. Test result shows the
about 15% improvement on full size GSO packet receiving (and even better than
before commit 2613af0ed18a11d5c566a81f9a6510b73180660a).
Before this commit:
./netperf -H 192.168.100.4
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.100.4
() port 0 AF_INET : demo
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 10.00 20303.87
After this commit:
./netperf -H 192.168.100.4
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.100.4
() port 0 AF_INET : demo
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 10.00 23841.26
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Michael Dalton <mwdalton@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V2:
- call put_page() instead of depending on skb_coalesce_rx_frag()
---
drivers/net/virtio_net.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 113ee93..50774ae 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -305,7 +305,7 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb)
struct sk_buff *curr_skb = head_skb;
char *buf;
struct page *page;
- int num_buf, len;
+ int num_buf, len, offset;
num_buf = hdr->mhdr.num_buffers;
while (--num_buf) {
@@ -342,9 +342,16 @@ static int receive_mergeable(struct receive_queue *rq, struct sk_buff *head_skb)
head_skb->truesize += MAX_PACKET_LEN;
}
page = virt_to_head_page(buf);
- skb_add_rx_frag(curr_skb, num_skb_frags, page,
- buf - (char *)page_address(page), len,
- MAX_PACKET_LEN);
+ offset = buf - (char *)page_address(page);
+ if (skb_can_coalesce(curr_skb, num_skb_frags, page, offset)) {
+ put_page(page);
+ skb_coalesce_rx_frag(curr_skb, num_skb_frags - 1,
+ len, MAX_PACKET_LEN);
+ } else {
+ skb_add_rx_frag(curr_skb, num_skb_frags, page,
+ offset, len,
+ MAX_PACKET_LEN);
+ }
--rq->num;
}
return 0;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
@ 2013-11-01 9:47 ` Eric Dumazet
2013-11-05 1:04 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2013-11-01 9:47 UTC (permalink / raw)
To: Jason Wang
Cc: mwdalton, mst, netdev, linux-kernel, virtualization, kmindg,
edumazet, davem
On Fri, 2013-11-01 at 14:07 +0800, Jason Wang wrote:
> Commit 2613af0ed18a11d5c566a81f9a6510b73180660a (virtio_net: migrate mergeable
> rx buffers to page frag allocators) try to increase the payload/truesize for
> MTU-sized traffic. But this will introduce the extra overhead for GSO packets
> received because of the frag list. This commit tries to reduce this issue by
> coalesce the possible rx frags when possible during rx. Test result shows the
> about 15% improvement on full size GSO packet receiving (and even better than
> before commit 2613af0ed18a11d5c566a81f9a6510b73180660a).
>
> Before this commit:
> ./netperf -H 192.168.100.4
> MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.100.4
> () port 0 AF_INET : demo
> Recv Send Send
> Socket Socket Message Elapsed
> Size Size Size Time Throughput
> bytes bytes bytes secs. 10^6bits/sec
>
> 87380 16384 16384 10.00 20303.87
>
> After this commit:
> ./netperf -H 192.168.100.4
> MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.100.4
> () port 0 AF_INET : demo
> Recv Send Send
> Socket Socket Message Elapsed
> Size Size Size Time Throughput
> bytes bytes bytes secs. 10^6bits/sec
>
> 87380 16384 16384 10.00 23841.26
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Dalton <mwdalton@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Acked-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> Changes from V2:
> - call put_page() instead of depending on skb_coalesce_rx_frag()
> ---
Yes, very nice improvement, thanks again !
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
2013-11-01 9:47 ` Eric Dumazet
@ 2013-11-05 1:04 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2013-11-05 1:04 UTC (permalink / raw)
To: jasowang
Cc: mwdalton, mst, netdev, linux-kernel, virtualization, kmindg,
edumazet
From: Jason Wang <jasowang@redhat.com>
Date: Fri, 1 Nov 2013 14:07:48 +0800
> Commit 2613af0ed18a11d5c566a81f9a6510b73180660a (virtio_net: migrate mergeable
> rx buffers to page frag allocators) try to increase the payload/truesize for
> MTU-sized traffic. But this will introduce the extra overhead for GSO packets
> received because of the frag list. This commit tries to reduce this issue by
> coalesce the possible rx frags when possible during rx. Test result shows the
> about 15% improvement on full size GSO packet receiving (and even better than
> before commit 2613af0ed18a11d5c566a81f9a6510b73180660a).
...
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Dalton <mwdalton@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Acked-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> Changes from V2:
> - call put_page() instead of depending on skb_coalesce_rx_frag()
Looks fantastic, applied, thanks Jason!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag()
2013-11-01 6:07 [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Jason Wang
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
@ 2013-11-01 9:45 ` Eric Dumazet
2013-11-05 1:04 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2013-11-01 9:45 UTC (permalink / raw)
To: Jason Wang
Cc: mwdalton, mst, netdev, linux-kernel, virtualization, kmindg,
edumazet, davem
On Fri, 2013-11-01 at 14:07 +0800, Jason Wang wrote:
> Sometimes we need to coalesce the rx frags to avoid frag list. One example is
> virtio-net driver which tries to use small frags for both MTU sized packet and
> GSO packet. So this patch introduce skb_coalesce_rx_frag() to do this.
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Dalton <mwdalton@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> Changes from V2:
> - remove the skb_frag_unref() and let the called to put the page reference
> Changes from V1:
> - remove the useless off parameter.
> ---
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag()
2013-11-01 6:07 [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Jason Wang
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
2013-11-01 9:45 ` [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Eric Dumazet
@ 2013-11-05 1:04 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-11-05 1:04 UTC (permalink / raw)
To: jasowang
Cc: mwdalton, mst, netdev, linux-kernel, virtualization, kmindg,
edumazet
From: Jason Wang <jasowang@redhat.com>
Date: Fri, 1 Nov 2013 14:07:47 +0800
> Sometimes we need to coalesce the rx frags to avoid frag list. One example is
> virtio-net driver which tries to use small frags for both MTU sized packet and
> GSO packet. So this patch introduce skb_coalesce_rx_frag() to do this.
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Michael Dalton <mwdalton@google.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> Changes from V2:
> - remove the skb_frag_unref() and let the called to put the page reference
> Changes from V1:
> - remove the useless off parameter.
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-05 1:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01 6:07 [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Jason Wang
2013-11-01 6:07 ` [PATCH net-next V3 2/2] virtio-net: coalesce rx frags when possible during rx Jason Wang
2013-11-01 9:47 ` Eric Dumazet
2013-11-05 1:04 ` David Miller
2013-11-01 9:45 ` [PATCH net-next V3 1/2] net: introduce skb_coalesce_rx_frag() Eric Dumazet
2013-11-05 1:04 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).