From: Jason Wang <hidden> Date: 2016-12-23 14:37:42
Merry Xmas and a Happy New year to all:
This series tries to fixes several issues for virtio-net XDP which
could be categorized into several parts:
- fix several issues during XDP linearizing
- allow csumed packet to work for XDP_PASS
- make EWMA rxbuf size estimation works for XDP
- forbid XDP when GUEST_UFO is support
- remove big packet XDP support
- add XDP support or small buffer
Please see individual patches for details.
Thanks
Jason Wang (9):
virtio-net: remove the warning before XDP linearizing
virtio-net: correctly xmit linearized page on XDP_TX
virtio-net: fix page miscount during XDP linearizing
virtio-net: correctly handle XDP_PASS for linearized packets
virtio-net: unbreak csumed packets for XDP_PASS
virtio-net: make rx buf size estimation works for XDP
virtio-net: forbid XDP when VIRTIO_NET_F_GUEST_UFO is support
virtio-net: remove big packet XDP codes
virtio-net: XDP support for small buffers
drivers/net/virtio_net.c | 172 ++++++++++++++++++++++++++++-------------------
1 file changed, 102 insertions(+), 70 deletions(-)
--
2.7.4
From: Jason Wang <hidden> Date: 2016-12-23 14:38:26
Since we use EWMA to estimate the size of rx buffer. When rx buffer
size is underestimated, it's usual to have a packet with more than one
buffers. Consider this is not a bug, remove the warning and correct
the comment before XDP linearizing.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
@@ -552,14 +552,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,structpage*xdp_page;u32act;-/* No known backend devices should send packets with-*morethanasinglebufferwhenXDPconditionsare-*met.Howeveritisnotstrictlyillegalsothecase-*ishandledasanexceptionandawarningisthrown.-*/+/* This happens when rx buffer size is underestimated */if(unlikely(num_buf>1)){-bpf_warn_invalid_xdp_buffer();-/* linearize data for XDP */xdp_page=xdp_linearize_page(rq,num_buf,page,offset,&len);
From: Jason Wang <hidden> Date: 2016-12-23 14:38:28
When XDP_PASS were determined for linearized packets, we try to get
new buffers in the virtqueue and build skbs from them. This is wrong,
we should create skbs based on existed buffers instead. Fixing them by
creating skb based on xdp_page.
With this patch "ping 192.168.100.4 -s 3900 -M do" works for XDP_PASS.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
@@ -578,8 +578,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,act=do_xdp_prog(vi,rq,xdp_prog,xdp_page,offset,len);switch(act){caseXDP_PASS:-if(unlikely(xdp_page!=page))-__free_pages(xdp_page,0);+/* We can only create skb based on xdp_page. */+if(unlikely(xdp_page!=page)){+rcu_read_unlock();+put_page(page);+head_skb=page_to_skb(vi,rq,xdp_page,+0,len,PAGE_SIZE);+returnhead_skb;+}break;caseXDP_TX:if(unlikely(xdp_page!=page))
From: Jason Wang <hidden> Date: 2016-12-23 14:38:30
After we linearize page, we should xmit this page instead of the page
of first buffer which may lead unexpected result. With this patch, we
can see correct packet during XDP_TX.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jason Wang <hidden> Date: 2016-12-23 14:38:31
We don't put page during linearizing, the would cause leaking when
xmit through XDP_TX or the packet exceeds PAGE_SIZE. Fix them by
put page accordingly. Also decrease the number of buffers during
linearizing to make sure caller can free buffers correctly when packet
exceeds PAGE_SIZE. With this patch, we won't get OOM after linearize
huge number of packets.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
@@ -507,19 +507,22 @@ static struct page *xdp_linearize_page(struct receive_queue *rq,if(unlikely(!ctx))gotoerr_buf;+buf=mergeable_ctx_to_buf_address(ctx);+p=virt_to_head_page(buf);+off=buf-page_address(p);+/* guard against a misconfigured or uncooperative backend that*issendingpacketlargerthantheMTU.*/-if((page_off+buflen)>PAGE_SIZE)+if((page_off+buflen)>PAGE_SIZE){+put_page(p);gotoerr_buf;--buf=mergeable_ctx_to_buf_address(ctx);-p=virt_to_head_page(buf);-off=buf-page_address(p);+}memcpy(page_address(page)+page_off,page_address(p)+off,buflen);page_off+=buflen;+put_page(p);}*len=page_off;
@@ -555,7 +558,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,/* This happens when rx buffer size is underestimated */if(unlikely(num_buf>1)){/* linearize data for XDP */-xdp_page=xdp_linearize_page(rq,num_buf,+xdp_page=xdp_linearize_page(rq,&num_buf,page,offset,&len);if(!xdp_page)gotoerr_xdp;
From: Jason Wang <hidden> Date: 2016-12-23 14:39:30
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 112 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 25 deletions(-)
@@ -343,20 +343,45 @@ static void virtnet_xdp_xmit(struct virtnet_info *vi,/* Free up any pending old buffers before queueing new ones. */while((xdp_sent=virtqueue_get_buf(sq->vq,&len))!=NULL){-structpage*sent_page=virt_to_head_page(xdp_sent);-put_page(sent_page);+if(vi->mergeable_rx_bufs){+structpage*sent_page=virt_to_head_page(xdp_sent);++put_page(sent_page);+}else{/* small buffer */+structsk_buff*skb=xdp_sent;++kfree_skb(skb);+}}-/* Zero header and leave csum up to XDP layers */-hdr=xdp->data;-memset(hdr,0,vi->hdr_len);+if(vi->mergeable_rx_bufs){+/* Zero header and leave csum up to XDP layers */+hdr=xdp->data;+memset(hdr,0,vi->hdr_len);++num_sg=1;+sg_init_one(sq->sg,xdp->data,xdp->data_end-xdp->data);+}else{/* small buffer */+structsk_buff*skb=data;-num_sg=1;-sg_init_one(sq->sg,xdp->data,xdp->data_end-xdp->data);+/* Zero header and leave csum up to XDP layers */+hdr=skb_vnet_hdr(skb);+memset(hdr,0,vi->hdr_len);++num_sg=2;+sg_init_table(sq->sg,2);+sg_set_buf(sq->sg,hdr,vi->hdr_len);+skb_to_sgvec(skb,sq->sg+1,0,skb->len);+}err=virtqueue_add_outbuf(sq->vq,sq->sg,num_sg,-xdp->data,GFP_ATOMIC);+data,GFP_ATOMIC);if(unlikely(err)){-put_page(page);+if(vi->mergeable_rx_bufs){+structpage*page=virt_to_head_page(xdp->data);++put_page(page);+}else/* small buffer */+kfree_skb(data);return;// On error abort to avoid unnecessary kick}
@@ -537,7 +598,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,if(unlikely(hdr->hdr.gso_type))gotoerr_xdp;-act=do_xdp_prog(vi,rq,xdp_prog,xdp_page,offset,len);+act=do_xdp_prog(vi,rq,xdp_prog,+page_address(xdp_page)+offset,len);switch(act){caseXDP_PASS:/* We can only create skb based on xdp_page. */
From: Jason Wang <hidden> Date: 2016-12-23 14:39:33
Now we in fact don't allow XDP for big packets, remove its codes.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 44 +++-----------------------------------------
1 file changed, 3 insertions(+), 41 deletions(-)
@@ -344,11 +344,7 @@ static void virtnet_xdp_xmit(struct virtnet_info *vi,/* Free up any pending old buffers before queueing new ones. */while((xdp_sent=virtqueue_get_buf(sq->vq,&len))!=NULL){structpage*sent_page=virt_to_head_page(xdp_sent);--if(vi->mergeable_rx_bufs)-put_page(sent_page);-else-give_pages(rq,sent_page);+put_page(sent_page);}/* Zero header and leave csum up to XDP layers */
@@ -360,15 +356,8 @@ static void virtnet_xdp_xmit(struct virtnet_info *vi,err=virtqueue_add_outbuf(sq->vq,sq->sg,num_sg,xdp->data,GFP_ATOMIC);if(unlikely(err)){-if(vi->mergeable_rx_bufs)-put_page(page);-else-give_pages(rq,page);+put_page(page);return;// On error abort to avoid unnecessary kick-}elseif(!vi->mergeable_rx_bufs){-/* If not mergeable bufs must be big packets so cleanup pages */-give_pages(rq,(structpage*)page->private);-page->private=0;}virtqueue_kick(sq->vq);
From: Jason Wang <hidden> Date: 2016-12-23 14:39:34
When VIRTIO_NET_F_GUEST_UFO is negotiated, host could still send UFO
packet that exceeds a single page which could not be handled
correctly by XDP. So this patch forbids setting XDP when GUEST_UFO is
supported. While at it, forbid XDP for ECN (which comes only from GRO)
too to prevent user from misconfiguration.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
From: Jason Wang <hidden> Date: 2016-12-23 14:39:36
We don't update ewma rx buf size in the case of XDP. This will lead
underestimation of rx buf size which causes host to produce more than
one buffers. This will greatly increase the possibility of XDP page
linearization.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 3 +++
1 file changed, 3 insertions(+)
From: Jason Wang <hidden> Date: 2016-12-23 14:40:57
We drop csumed packet when do XDP for packets. This breaks
XDP_PASS when GUEST_CSUM is supported. Fix this by allowing csum flag
to be set. With this patch, simple TCP works for XDP_PASS.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 15:47:50
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted hunk
After we linearize page, we should xmit this page instead of the page
of first buffer which may lead unexpected result. With this patch, we
can see correct packet during XDP_TX.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 15:54:30
On 16-12-23 06:37 AM, Jason Wang wrote:
We don't put page during linearizing, the would cause leaking when
xmit through XDP_TX or the packet exceeds PAGE_SIZE. Fix them by
put page accordingly. Also decrease the number of buffers during
linearizing to make sure caller can free buffers correctly when packet
exceeds PAGE_SIZE. With this patch, we won't get OOM after linearize
huge number of packets.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
Thanks! looks good. By the way do you happen to have any actual
configuration where this path is hit? I obviously didn't test this
very long other than a quick test with my hacked vhost driver.
Acked-by: John Fastabend <redacted>
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 15:57:42
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted hunk
When XDP_PASS were determined for linearized packets, we try to get
new buffers in the virtqueue and build skbs from them. This is wrong,
we should create skbs based on existed buffers instead. Fixing them by
creating skb based on xdp_page.
With this patch "ping 192.168.100.4 -s 3900 -M do" works for XDP_PASS.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
@@ -578,8 +578,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,act=do_xdp_prog(vi,rq,xdp_prog,xdp_page,offset,len);switch(act){caseXDP_PASS:-if(unlikely(xdp_page!=page))-__free_pages(xdp_page,0);+/* We can only create skb based on xdp_page. */+if(unlikely(xdp_page!=page)){+rcu_read_unlock();+put_page(page);+head_skb=page_to_skb(vi,rq,xdp_page,+0,len,PAGE_SIZE);+returnhead_skb;+}break;caseXDP_TX:if(unlikely(xdp_page!=page))
Great thanks. This was likely working before because of the memory
leak fixed in 3/9.
Acked-by: John Fastabend <redacted>
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 15:58:27
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted hunk
We drop csumed packet when do XDP for packets. This breaks
XDP_PASS when GUEST_CSUM is supported. Fix this by allowing csum flag
to be set. With this patch, simple TCP works for XDP_PASS.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 16:02:36
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted hunk
We don't update ewma rx buf size in the case of XDP. This will lead
underestimation of rx buf size which causes host to produce more than
one buffers. This will greatly increase the possibility of XDP page
linearization.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 3 +++
1 file changed, 3 insertions(+)
Looks needed although I guess it will only be the case with
MTU > ETH_DATA_LEN because of the clamp in get_mergeable_buf_len().
Although XDP setup allows MTU up to page_size - hdr so certainly
will happen with ~MTU > 1500.
I need to add some various MTU tests to my setup.
Acked-by: John Fastabend <redacted>
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 16:03:15
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted hunk
When VIRTIO_NET_F_GUEST_UFO is negotiated, host could still send UFO
packet that exceeds a single page which could not be handled
correctly by XDP. So this patch forbids setting XDP when GUEST_UFO is
supported. While at it, forbid XDP for ECN (which comes only from GRO)
too to prevent user from misconfiguration.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 16:10:23
On 16-12-23 08:02 AM, John Fastabend wrote:
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
When VIRTIO_NET_F_GUEST_UFO is negotiated, host could still send UFO
packet that exceeds a single page which could not be handled
correctly by XDP. So this patch forbids setting XDP when GUEST_UFO is
supported. While at it, forbid XDP for ECN (which comes only from GRO)
too to prevent user from misconfiguration.
Is sending packets greater than single page though normal in this case?
I don't have any need to support big packet mode other than MST asked
for it. And I wasn't seeing this in my tests. MTU is capped at 4k - hdr
when XDP is enabled.
.John
quoted
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 16:53:13
On 16-12-23 06:37 AM, Jason Wang wrote:
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
Looks good to me thanks!
Acked-by: John Fastabend <redacted>
From: John Fastabend <john.fastabend@gmail.com> Date: 2016-12-23 17:10:27
On 16-12-23 06:37 AM, Jason Wang wrote:
Merry Xmas and a Happy New year to all:
This series tries to fixes several issues for virtio-net XDP which
could be categorized into several parts:
- fix several issues during XDP linearizing
- allow csumed packet to work for XDP_PASS
- make EWMA rxbuf size estimation works for XDP
- forbid XDP when GUEST_UFO is support
- remove big packet XDP support
- add XDP support or small buffer
Please see individual patches for details.
Thanks
Jason Wang (9):
virtio-net: remove the warning before XDP linearizing
virtio-net: correctly xmit linearized page on XDP_TX
virtio-net: fix page miscount during XDP linearizing
virtio-net: correctly handle XDP_PASS for linearized packets
virtio-net: unbreak csumed packets for XDP_PASS
virtio-net: make rx buf size estimation works for XDP
virtio-net: forbid XDP when VIRTIO_NET_F_GUEST_UFO is support
virtio-net: remove big packet XDP codes
virtio-net: XDP support for small buffers
drivers/net/virtio_net.c | 172 ++++++++++++++++++++++++++++-------------------
1 file changed, 102 insertions(+), 70 deletions(-)
Thanks a lot Jason. The last piece that is needed is support to
complete XDP support is to get the adjust_head part correct. I'll
send out a patch in a bit but will need to merge it on top of this
set.
.John
From: David Miller <davem@davemloft.net> Date: 2016-12-23 18:49:16
From: Jason Wang <redacted>
Date: Fri, 23 Dec 2016 22:37:23 +0800
Merry Xmas and a Happy New year to all:
This series tries to fixes several issues for virtio-net XDP which
could be categorized into several parts:
- fix several issues during XDP linearizing
- allow csumed packet to work for XDP_PASS
- make EWMA rxbuf size estimation works for XDP
- forbid XDP when GUEST_UFO is support
- remove big packet XDP support
- add XDP support or small buffer
Please see individual patches for details.
From: Daniel Borkmann <daniel@iogearbox.net> Date: 2016-12-23 19:32:01
Hi Jason,
On 12/23/2016 03:37 PM, Jason Wang wrote:
quoted hunk
Since we use EWMA to estimate the size of rx buffer. When rx buffer
size is underestimated, it's usual to have a packet with more than one
buffers. Consider this is not a bug, remove the warning and correct
the comment before XDP linearizing.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
@@ -552,14 +552,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,structpage*xdp_page;u32act;-/* No known backend devices should send packets with-*morethanasinglebufferwhenXDPconditionsare-*met.Howeveritisnotstrictlyillegalsothecase-*ishandledasanexceptionandawarningisthrown.-*/+/* This happens when rx buffer size is underestimated */if(unlikely(num_buf>1)){-bpf_warn_invalid_xdp_buffer();
Could you also remove the bpf_warn_invalid_xdp_buffer(), which got added
just for this?
Thanks.
/* linearize data for XDP */
xdp_page = xdp_linearize_page(rq, num_buf,
page, offset, &len);
From: Jason Wang <hidden> Date: 2016-12-26 02:30:19
On 2016年12月23日 23:54, John Fastabend wrote:
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
We don't put page during linearizing, the would cause leaking when
xmit through XDP_TX or the packet exceeds PAGE_SIZE. Fix them by
put page accordingly. Also decrease the number of buffers during
linearizing to make sure caller can free buffers correctly when packet
exceeds PAGE_SIZE. With this patch, we won't get OOM after linearize
huge number of packets.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
Thanks! looks good. By the way do you happen to have any actual
configuration where this path is hit? I obviously didn't test this
very long other than a quick test with my hacked vhost driver.
Acked-by: John Fastabend <redacted>
Yes, I have. Just increase the MTU above 1500 for both virtio and tap
and produce some traffic with size which will lead underestimated of rxbuf.
Thanks
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
From: Jason Wang <hidden> Date: 2016-12-26 02:34:48
On 2016年12月23日 23:57, John Fastabend wrote:
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
When XDP_PASS were determined for linearized packets, we try to get
new buffers in the virtqueue and build skbs from them. This is wrong,
we should create skbs based on existed buffers instead. Fixing them by
creating skb based on xdp_page.
With this patch "ping 192.168.100.4 -s 3900 -M do" works for XDP_PASS.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
@@ -578,8 +578,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,act=do_xdp_prog(vi,rq,xdp_prog,xdp_page,offset,len);switch(act){caseXDP_PASS:-if(unlikely(xdp_page!=page))-__free_pages(xdp_page,0);+/* We can only create skb based on xdp_page. */+if(unlikely(xdp_page!=page)){+rcu_read_unlock();+put_page(page);+head_skb=page_to_skb(vi,rq,xdp_page,+0,len,PAGE_SIZE);+returnhead_skb;+}break;caseXDP_TX:if(unlikely(xdp_page!=page))
Great thanks. This was likely working before because of the memory
leak fixed in 3/9.
Looks not, without this and 3/9 the code will try to get buffers and
build skb for a new packet instead of existed buffers.
Thanks
From: Jason Wang <hidden> Date: 2016-12-26 02:38:25
On 2016年12月24日 00:10, John Fastabend wrote:
On 16-12-23 08:02 AM, John Fastabend wrote:
quoted
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
When VIRTIO_NET_F_GUEST_UFO is negotiated, host could still send UFO
packet that exceeds a single page which could not be handled
correctly by XDP. So this patch forbids setting XDP when GUEST_UFO is
supported. While at it, forbid XDP for ECN (which comes only from GRO)
too to prevent user from misconfiguration.
Is sending packets greater than single page though normal in this case?
Yes, when NETIF_F_UFO was enabled for tap, it won't segment UFO packet
and will send it directly to guest. (This could be reproduced with
UDP_STREAM between two guests or host to guest).
Thanks
I don't have any need to support big packet mode other than MST asked
for it. And I wasn't seeing this in my tests. MTU is capped at 4k - hdr
when XDP is enabled.
.John
quoted
quoted
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
From: Jason Wang <hidden> Date: 2016-12-26 02:39:26
On 2016年12月24日 01:10, John Fastabend wrote:
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
Merry Xmas and a Happy New year to all:
This series tries to fixes several issues for virtio-net XDP which
could be categorized into several parts:
- fix several issues during XDP linearizing
- allow csumed packet to work for XDP_PASS
- make EWMA rxbuf size estimation works for XDP
- forbid XDP when GUEST_UFO is support
- remove big packet XDP support
- add XDP support or small buffer
Please see individual patches for details.
Thanks
Jason Wang (9):
virtio-net: remove the warning before XDP linearizing
virtio-net: correctly xmit linearized page on XDP_TX
virtio-net: fix page miscount during XDP linearizing
virtio-net: correctly handle XDP_PASS for linearized packets
virtio-net: unbreak csumed packets for XDP_PASS
virtio-net: make rx buf size estimation works for XDP
virtio-net: forbid XDP when VIRTIO_NET_F_GUEST_UFO is support
virtio-net: remove big packet XDP codes
virtio-net: XDP support for small buffers
drivers/net/virtio_net.c | 172 ++++++++++++++++++++++++++++-------------------
1 file changed, 102 insertions(+), 70 deletions(-)
Thanks a lot Jason. The last piece that is needed is support to
complete XDP support is to get the adjust_head part correct. I'll
send out a patch in a bit but will need to merge it on top of this
set.
.John
From: Jason Wang <hidden> Date: 2016-12-27 03:08:44
On 2016年12月24日 03:31, Daniel Borkmann wrote:
Hi Jason,
On 12/23/2016 03:37 PM, Jason Wang wrote:
quoted
Since we use EWMA to estimate the size of rx buffer. When rx buffer
size is underestimated, it's usual to have a packet with more than one
buffers. Consider this is not a bug, remove the warning and correct
the comment before XDP linearizing.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
net_device *dev,
struct page *xdp_page;
u32 act;
- /* No known backend devices should send packets with
- * more than a single buffer when XDP conditions are
- * met. However it is not strictly illegal so the case
- * is handled as an exception and a warning is thrown.
- */
+ /* This happens when rx buffer size is underestimated */
if (unlikely(num_buf > 1)) {
- bpf_warn_invalid_xdp_buffer();
Could you also remove the bpf_warn_invalid_xdp_buffer(), which got added
just for this?
Thanks.
From: John Fastabend <john.fastabend@gmail.com> Date: 2017-01-02 22:44:13
On 16-12-23 06:37 AM, Jason Wang wrote:
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 112 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 25 deletions(-)
Hi Jason,
I was doing some more testing on this what do you think about doing this
so that free_unused_bufs() handles the buffer free with dev_kfree_skb()
instead of put_page in small receive mode. Seems more correct to me.
From: Jason Wang <hidden> Date: 2017-01-03 06:16:47
On 2017年01月03日 06:43, John Fastabend wrote:
quoted hunk
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 112 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 25 deletions(-)
Hi Jason,
I was doing some more testing on this what do you think about doing this
so that free_unused_bufs() handles the buffer free with dev_kfree_skb()
instead of put_page in small receive mode. Seems more correct to me.
@@ -1898,6 +1898,10 @@ static void free_receive_page_frags(struct virtnet_info *vi)staticboolis_xdp_queue(structvirtnet_info*vi,intq){+/* For small receive mode always use kfree_skb variants */+if(!vi->mergeable_rx_bufs)+returnfalse;+if(q<(vi->curr_queue_pairs-vi->xdp_queue_pairs))returnfalse;elseif(q<vi->curr_queue_pairs)
patch is untested just spotted doing code review.
Thanks,
John
We probably need a better name for this function.
Acked-by: Jason Wang <redacted>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
From: John Fastabend <john.fastabend@gmail.com> Date: 2017-01-03 16:41:00
On 17-01-02 10:16 PM, Jason Wang wrote:
On 2017年01月03日 06:43, John Fastabend wrote:
quoted
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 112 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 25 deletions(-)
Hi Jason,
I was doing some more testing on this what do you think about doing this
so that free_unused_bufs() handles the buffer free with dev_kfree_skb()
instead of put_page in small receive mode. Seems more correct to me.
*vi)
static bool is_xdp_queue(struct virtnet_info *vi, int q)
{
+ /* For small receive mode always use kfree_skb variants */
+ if (!vi->mergeable_rx_bufs)
+ return false;
+
if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs))
return false;
else if (q < vi->curr_queue_pairs)
patch is untested just spotted doing code review.
Thanks,
John
We probably need a better name for this function.
Acked-by: Jason Wang <redacted>
From: Jason Wang <hidden> Date: 2017-01-04 03:15:04
On 2017年01月04日 00:40, John Fastabend wrote:
On 17-01-02 10:16 PM, Jason Wang wrote:
quoted
On 2017年01月03日 06:43, John Fastabend wrote:
quoted
On 16-12-23 06:37 AM, Jason Wang wrote:
quoted
Commit f600b6905015 ("virtio_net: Add XDP support") leaves the case of
small receive buffer untouched. This will confuse the user who want to
set XDP but use small buffers. Other than forbid XDP in small buffer
mode, let's make it work. XDP then can only work at skb->data since
virtio-net create skbs during refill, this is sub optimal which could
be optimized in the future.
Cc: John Fastabend <redacted>
Signed-off-by: Jason Wang <redacted>
---
drivers/net/virtio_net.c | 112 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 25 deletions(-)
Hi Jason,
I was doing some more testing on this what do you think about doing this
so that free_unused_bufs() handles the buffer free with dev_kfree_skb()
instead of put_page in small receive mode. Seems more correct to me.
*vi)
static bool is_xdp_queue(struct virtnet_info *vi, int q)
{
+ /* For small receive mode always use kfree_skb variants */
+ if (!vi->mergeable_rx_bufs)
+ return false;
+
if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs))
return false;
else if (q < vi->curr_queue_pairs)
patch is untested just spotted doing code review.
Thanks,
John
We probably need a better name for this function.
Acked-by: Jason Wang <redacted>
How about is_xdp_raw_buffer_queue()?
I'll submit a proper patch today.