From: Jason Wang <jasowang@redhat.com>
To: John Fastabend <john.fastabend@gmail.com>,
mst@redhat.com, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] virtio-net: switch to use build_skb() for small buffer
Date: Thu, 23 Feb 2017 10:44:27 +0800 [thread overview]
Message-ID: <f282bbae-7399-6d46-21e1-429310f7b0e4@redhat.com> (raw)
In-Reply-To: <58ADC790.8000805@gmail.com>
On 2017年02月23日 01:17, John Fastabend wrote:
> On 17-02-21 12:46 AM, Jason Wang wrote:
>> This patch switch to use build_skb() for small buffer which can have
>> better performance for both TCP and XDP (since we can work at page
>> before skb creation). It also remove lots of XDP codes since both
>> mergeable and small buffer use page frag during refill now.
>>
>> Before | After
>> XDP_DROP(xdp1) 64B : 11.1Mpps | 14.4Mpps
>>
>> Tested with xdp1/xdp2/xdp_ip_tx_tunnel and netperf.
> When you do the xdp tests are you generating packets with pktgen on the
> corresponding tap devices?
Yes, pktgen on the tap directly.
>
> Also another thought, have you looked at using some of the buffer recycling
> techniques used in the hardware drivers such as ixgbe and with Eric's latest
> patches mlx? I have seen significant performance increases for some
> workloads doing this. I wanted to try something like this out on virtio
> but haven't had time yet.
Yes, this is in TODO list. Will pick some time to do this.
Thanks
>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
> [...]
>
>> static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
>> gfp_t gfp)
>> {
>> - int headroom = GOOD_PACKET_LEN + virtnet_get_headroom(vi);
>> + struct page_frag *alloc_frag = &rq->alloc_frag;
>> + char *buf;
>> unsigned int xdp_headroom = virtnet_get_headroom(vi);
>> - struct sk_buff *skb;
>> - struct virtio_net_hdr_mrg_rxbuf *hdr;
>> + int len = vi->hdr_len + VIRTNET_RX_PAD + GOOD_PACKET_LEN + xdp_headroom;
>> int err;
>>
>> - skb = __netdev_alloc_skb_ip_align(vi->dev, headroom, gfp);
>> - if (unlikely(!skb))
>> + len = SKB_DATA_ALIGN(len) +
>> + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>> + if (unlikely(!skb_page_frag_refill(len, alloc_frag, gfp)))
>> return -ENOMEM;
>>
>> - skb_put(skb, headroom);
>> -
>> - hdr = skb_vnet_hdr(skb);
>> - sg_init_table(rq->sg, 2);
>> - sg_set_buf(rq->sg, hdr, vi->hdr_len);
>> - skb_to_sgvec(skb, rq->sg + 1, xdp_headroom, skb->len - xdp_headroom);
>> -
>> - err = virtqueue_add_inbuf(rq->vq, rq->sg, 2, skb, gfp);
>> + buf = (char *)page_address(alloc_frag->page) + alloc_frag->offset;
>> + get_page(alloc_frag->page);
>> + alloc_frag->offset += len;
>> + sg_init_one(rq->sg, buf + VIRTNET_RX_PAD + xdp_headroom,
>> + vi->hdr_len + GOOD_PACKET_LEN);
>> + err = virtqueue_add_inbuf(rq->vq, rq->sg, 1, buf, gfp);
> Nice this cleans up a lot of the branching code. Thanks.
>
> Acked-by: John Fastabend <john.r.fastabend@intel.com>
prev parent reply other threads:[~2017-02-23 2:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 8:46 [PATCH net-next] virtio-net: switch to use build_skb() for small buffer Jason Wang
2017-02-21 14:37 ` Michael S. Tsirkin
2017-02-22 2:58 ` Jason Wang
2017-02-22 3:06 ` Michael S. Tsirkin
2017-02-22 3:17 ` Jason Wang
2017-02-22 3:38 ` Jason Wang
2017-02-22 3:42 ` Michael S. Tsirkin
2017-02-22 10:36 ` Jason Wang
2017-02-21 17:26 ` David Miller
2017-02-22 17:17 ` John Fastabend
2017-02-23 2:44 ` Jason Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f282bbae-7399-6d46-21e1-429310f7b0e4@redhat.com \
--to=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).