Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1691136 > unrolled thread
| Started by | Jason Wang <jasowang@redhat.com> |
|---|---|
| First post | 2017-07-19 11:00 +0200 |
| Last post | 2017-07-24 23:50 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH net-next V2 0/5] Refine virtio-net XDP Jason Wang <jasowang@redhat.com> - 2017-07-19 11:00 +0200
[PATCH net-next V2 2/5] virtio-net: pack headroom into ctx for mergeable buffers Jason Wang <jasowang@redhat.com> - 2017-07-19 11:00 +0200
Re: [PATCH net-next V2 0/5] Refine virtio-net XDP David Miller <davem@davemloft.net> - 2017-07-24 22:40 +0200
Re: [PATCH net-next V2 0/5] Refine virtio-net XDP "Michael S. Tsirkin" <mst@redhat.com> - 2017-07-24 23:50 +0200
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2017-07-19 11:00 +0200 |
| Subject | [PATCH net-next V2 0/5] Refine virtio-net XDP |
| Message-ID | <u4SZP-68j-5@gated-at.bofh.it> |
Hi: This series brings two optimizations for virtio-net XDP: - avoid reset during XDP set - turn off offloads on demand Changes from V1: - Various tweaks on commit logs and comments - Use virtnet_napi_enable() when enabling NAPI on XDP set - Copy the small buffer packet only if xdp_headroom is smaller than required Please review. Thanks Jason Wang (5): virtio_ring: allow to store zero as the ctx virtio-net: pack headroom into ctx for mergeable buffers virtio-net: switch to use new ctx API for small buffer virtio-net: do not reset during XDP set virtio-net: switch off offloads on demand if possible on XDP set drivers/net/virtio_net.c | 332 ++++++++++++++++++++++++++----------------- drivers/virtio/virtio_ring.c | 2 +- 2 files changed, 200 insertions(+), 134 deletions(-) -- 2.7.4
[toc] | [next] | [standalone]
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Date | 2017-07-19 11:00 +0200 |
| Subject | [PATCH net-next V2 2/5] virtio-net: pack headroom into ctx for mergeable buffers |
| Message-ID | <u4SZQ-68j-27@gated-at.bofh.it> |
| In reply to | #1691136 |
Pack headroom into ctx - this way when we get a buffer we can figure out
the actual headroom that was allocated for the buffer. Will be helpful
to optimize switching between XDP and non-XDP modes which have different
headroom requirements.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/virtio_net.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 1f8c15c..8fae9a8 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -270,6 +270,23 @@ static void skb_xmit_done(struct virtqueue *vq)
netif_wake_subqueue(vi->dev, vq2txq(vq));
}
+#define MRG_CTX_HEADER_SHIFT 22
+static void *mergeable_len_to_ctx(unsigned int truesize,
+ unsigned int headroom)
+{
+ return (void *)(unsigned long)((headroom << MRG_CTX_HEADER_SHIFT) | truesize);
+}
+
+static unsigned int mergeable_ctx_to_headroom(void *mrg_ctx)
+{
+ return (unsigned long)mrg_ctx >> MRG_CTX_HEADER_SHIFT;
+}
+
+static unsigned int mergeable_ctx_to_truesize(void *mrg_ctx)
+{
+ return (unsigned long)mrg_ctx & ((1 << MRG_CTX_HEADER_SHIFT) - 1);
+}
+
/* Called from bottom half context */
static struct sk_buff *page_to_skb(struct virtnet_info *vi,
struct receive_queue *rq,
@@ -639,13 +656,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
}
rcu_read_unlock();
- if (unlikely(len > (unsigned long)ctx)) {
+ truesize = mergeable_ctx_to_truesize(ctx);
+ if (unlikely(len > truesize)) {
pr_debug("%s: rx error: len %u exceeds truesize %lu\n",
dev->name, len, (unsigned long)ctx);
dev->stats.rx_length_errors++;
goto err_skb;
}
- truesize = (unsigned long)ctx;
+
head_skb = page_to_skb(vi, rq, page, offset, len, truesize);
curr_skb = head_skb;
@@ -665,13 +683,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
}
page = virt_to_head_page(buf);
- if (unlikely(len > (unsigned long)ctx)) {
+
+ truesize = mergeable_ctx_to_truesize(ctx);
+ if (unlikely(len > truesize)) {
pr_debug("%s: rx error: len %u exceeds truesize %lu\n",
dev->name, len, (unsigned long)ctx);
dev->stats.rx_length_errors++;
goto err_skb;
}
- truesize = (unsigned long)ctx;
num_skb_frags = skb_shinfo(curr_skb)->nr_frags;
if (unlikely(num_skb_frags == MAX_SKB_FRAGS)) {
@@ -889,7 +908,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi,
buf = (char *)page_address(alloc_frag->page) + alloc_frag->offset;
buf += headroom; /* advance address leaving hole at front of pkt */
- ctx = (void *)(unsigned long)len;
+ ctx = mergeable_len_to_ctx(len, headroom);
get_page(alloc_frag->page);
alloc_frag->offset += len + headroom;
hole = alloc_frag->size - alloc_frag->offset;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2017-07-24 22:40 +0200 |
| Message-ID | <u6Sj0-1xi-7@gated-at.bofh.it> |
| In reply to | #1691136 |
From: Jason Wang <jasowang@redhat.com> Date: Wed, 19 Jul 2017 16:54:44 +0800 > Hi: > > This series brings two optimizations for virtio-net XDP: > > - avoid reset during XDP set > - turn off offloads on demand > > Changes from V1: > - Various tweaks on commit logs and comments > - Use virtnet_napi_enable() when enabling NAPI on XDP set > - Copy the small buffer packet only if xdp_headroom is smaller than > required > > Please review. Series applied, thanks Jason. Michael, I gave you 4+ days to properly review this respin of this series. I felt that was more than sufficient time, even with an intervening weekend. So if you don't like that I applied this without your review, please be more punctual in the future. Thank you.
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2017-07-24 23:50 +0200 |
| Message-ID | <u6ToL-2fn-41@gated-at.bofh.it> |
| In reply to | #1695075 |
On Mon, Jul 24, 2017 at 01:38:59PM -0700, David Miller wrote: > From: Jason Wang <jasowang@redhat.com> > Date: Wed, 19 Jul 2017 16:54:44 +0800 > > > Hi: > > > > This series brings two optimizations for virtio-net XDP: > > > > - avoid reset during XDP set > > - turn off offloads on demand > > > > Changes from V1: > > - Various tweaks on commit logs and comments > > - Use virtnet_napi_enable() when enabling NAPI on XDP set > > - Copy the small buffer packet only if xdp_headroom is smaller than > > required > > > > Please review. > > Series applied, thanks Jason. > > Michael, I gave you 4+ days to properly review this respin of this > series. I felt that was more than sufficient time, even with an > intervening weekend. So if you don't like that I applied this without > your review, please be more punctual in the future. > > Thank you. My bad - reviewed when I was offline and forgot to send it out. By luck this is not a big deal: - Patches 1-4 are good. - Patch 5 has some problems IMO, but all it does is try to enable a previously non-working configuration, so it seems ok to fix it up with follow-up patches as appropriate. -- MST
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web