* [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support
@ 2017-01-13 0:34 John Fastabend
2017-01-13 0:35 ` [net PATCH v2 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: John Fastabend @ 2017-01-13 0:34 UTC (permalink / raw)
To: jasowang, mst
Cc: john.r.fastabend, netdev, john.fastabend, alexei.starovoitov,
daniel
This has a fix to handle small buffer free logic correctly and then
also adds adjust head support.
I pushed adjust head at net (even though its rc3) to avoid having
to push another exception case into virtio_net to catch if the
program uses adjust_head and then block it. If there are any strong
objections to this we can push it at net-next and use a patch from
Jakub to add the exception handling but then user space has to deal
with it either via try/fail logic or via kernel version checks. Granted
we already have some cases that need to be configured to enable XDP
but I don't see any reason to have yet another one when we can fix it
now vs delaying a kernel version.
v2: fix spelling error, convert unsigned -> unsigned int
---
John Fastabend (5):
virtio_net: use dev_kfree_skb for small buffer XDP receive
net: virtio: wrap rtnl_lock in test for calling with lock already held
virtio_net: factor out xdp handler for readability
virtio_net: remove duplicate queue pair binding in XDP
virtio_net: XDP support for adjust_head
drivers/net/virtio_net.c | 251 ++++++++++++++++++++++++++++++++--------------
drivers/virtio/virtio.c | 9 +-
include/linux/virtio.h | 3 +
3 files changed, 183 insertions(+), 80 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [net PATCH v2 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive
2017-01-13 0:34 [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
@ 2017-01-13 0:35 ` John Fastabend
2017-01-13 0:35 ` [net PATCH v2 2/5] net: virtio: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-01-13 2:54 ` [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2017-01-13 0:35 UTC (permalink / raw)
To: jasowang, mst
Cc: john.r.fastabend, netdev, john.fastabend, alexei.starovoitov,
daniel
In the small buffer case during driver unload we currently use
put_page instead of dev_kfree_skb. Resolve this by adding a check
for virtnet mode when checking XDP queue type. Also name the
function so that the code reads correctly to match the additional
check.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
drivers/net/virtio_net.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4a10500..d97bb71 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1890,8 +1890,12 @@ static void free_receive_page_frags(struct virtnet_info *vi)
put_page(vi->rq[i].alloc_frag.page);
}
-static bool is_xdp_queue(struct virtnet_info *vi, int q)
+static bool is_xdp_raw_buffer_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)
@@ -1908,7 +1912,7 @@ static void free_unused_bufs(struct virtnet_info *vi)
for (i = 0; i < vi->max_queue_pairs; i++) {
struct virtqueue *vq = vi->sq[i].vq;
while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) {
- if (!is_xdp_queue(vi, i))
+ if (!is_xdp_raw_buffer_queue(vi, i))
dev_kfree_skb(buf);
else
put_page(virt_to_head_page(buf));
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [net PATCH v2 2/5] net: virtio: wrap rtnl_lock in test for calling with lock already held
2017-01-13 0:34 [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-13 0:35 ` [net PATCH v2 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
@ 2017-01-13 0:35 ` John Fastabend
2017-01-13 2:54 ` [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2017-01-13 0:35 UTC (permalink / raw)
To: jasowang, mst
Cc: john.r.fastabend, netdev, john.fastabend, alexei.starovoitov,
daniel
For XDP use case and to allow ethtool reset tests it is useful to be
able to use reset routines from contexts where rtnl lock is already
held.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
drivers/net/virtio_net.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d97bb71..43cb2e0 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1864,12 +1864,13 @@ static void virtnet_free_queues(struct virtnet_info *vi)
kfree(vi->sq);
}
-static void free_receive_bufs(struct virtnet_info *vi)
+static void free_receive_bufs(struct virtnet_info *vi, bool need_lock)
{
struct bpf_prog *old_prog;
int i;
- rtnl_lock();
+ if (need_lock)
+ rtnl_lock();
for (i = 0; i < vi->max_queue_pairs; i++) {
while (vi->rq[i].pages)
__free_pages(get_a_page(&vi->rq[i], GFP_KERNEL), 0);
@@ -1879,7 +1880,8 @@ static void free_receive_bufs(struct virtnet_info *vi)
if (old_prog)
bpf_prog_put(old_prog);
}
- rtnl_unlock();
+ if (need_lock)
+ rtnl_unlock();
}
static void free_receive_page_frags(struct virtnet_info *vi)
@@ -2351,14 +2353,14 @@ static int virtnet_probe(struct virtio_device *vdev)
return err;
}
-static void remove_vq_common(struct virtnet_info *vi)
+static void remove_vq_common(struct virtnet_info *vi, bool lock)
{
vi->vdev->config->reset(vi->vdev);
/* Free unused buffers in both send and recv, if any. */
free_unused_bufs(vi);
- free_receive_bufs(vi);
+ free_receive_bufs(vi, lock);
free_receive_page_frags(vi);
@@ -2376,7 +2378,7 @@ static void virtnet_remove(struct virtio_device *vdev)
unregister_netdev(vi->dev);
- remove_vq_common(vi);
+ remove_vq_common(vi, true);
free_percpu(vi->stats);
free_netdev(vi->dev);
@@ -2401,7 +2403,7 @@ static int virtnet_freeze(struct virtio_device *vdev)
napi_disable(&vi->rq[i].napi);
}
- remove_vq_common(vi);
+ remove_vq_common(vi, true);
return 0;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support
2017-01-13 0:34 [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-13 0:35 ` [net PATCH v2 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-13 0:35 ` [net PATCH v2 2/5] net: virtio: wrap rtnl_lock in test for calling with lock already held John Fastabend
@ 2017-01-13 2:54 ` John Fastabend
2 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2017-01-13 2:54 UTC (permalink / raw)
To: jasowang, mst; +Cc: john.r.fastabend, netdev, alexei.starovoitov, daniel
On 17-01-12 04:34 PM, John Fastabend wrote:
> This has a fix to handle small buffer free logic correctly and then
> also adds adjust head support.
>
> I pushed adjust head at net (even though its rc3) to avoid having
> to push another exception case into virtio_net to catch if the
> program uses adjust_head and then block it. If there are any strong
> objections to this we can push it at net-next and use a patch from
> Jakub to add the exception handling but then user space has to deal
> with it either via try/fail logic or via kernel version checks. Granted
> we already have some cases that need to be configured to enable XDP
> but I don't see any reason to have yet another one when we can fix it
> now vs delaying a kernel version.
>
>
> v2: fix spelling error, convert unsigned -> unsigned int
>
> ---
Sorry about the v2 here I got a connection reset by peer error from
git and it seems only 2/5 patches made it to the list. To avoid as much
confusion as possible I just sent a v3 and it seems to have completed
correctly.
Thanks,
John
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-13 2:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-13 0:34 [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-13 0:35 ` [net PATCH v2 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-13 0:35 ` [net PATCH v2 2/5] net: virtio: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-01-13 2:54 ` [net PATCH v2 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.