* Re: [PATCH v6 1/2] virtio-net: introduce and use helper function for guest gso support checks [not found] ` <20220914144911.56422-2-gavinl@nvidia.com> @ 2022-09-22 1:39 ` Jason Wang 0 siblings, 0 replies; 4+ messages in thread From: Jason Wang @ 2022-09-22 1:39 UTC (permalink / raw) To: Gavin Li, mst, stephen, davem, jesse.brandeburg, kuba, sridhar.samudrala, loseweigh, netdev, virtualization, virtio-dev Cc: Gavi Teitz 在 2022/9/14 22:49, Gavin Li 写道: > Probe routine is already several hundred lines. > Use helper function for guest gso support check. > > Signed-off-by: Gavin Li <gavinl@nvidia.com> > Reviewed-by: Gavi Teitz <gavi@nvidia.com> > Reviewed-by: Parav Pandit <parav@nvidia.com> > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com> Acked-by: Jason Wang <jasowang@redhat.com> > --- > changelog: > v4->v5 > - Addressed comments from Michael S. Tsirkin > - Remove unnecessary () in return clause > v1->v2 > - Add new patch > --- > drivers/net/virtio_net.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index e0e57083d442..f54c7182758f 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -3682,6 +3682,14 @@ static int virtnet_validate(struct virtio_device *vdev) > return 0; > } > > +static bool virtnet_check_guest_gso(const struct virtnet_info *vi) > +{ > + return virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) || > + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || > + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || > + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO); > +} > + > static int virtnet_probe(struct virtio_device *vdev) > { > int i, err = -ENOMEM; > @@ -3777,10 +3785,7 @@ static int virtnet_probe(struct virtio_device *vdev) > spin_lock_init(&vi->refill_lock); > > /* If we can receive ANY GSO packets, we must allocate large ones. */ > - if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || > - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) || > - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) || > - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO)) > + if (virtnet_check_guest_gso(vi)) > vi->big_packets = true; > > if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20220914144911.56422-3-gavinl@nvidia.com>]
* Re: [PATCH v6 2/2] virtio-net: use mtu size as buffer length for big packets [not found] ` <20220914144911.56422-3-gavinl@nvidia.com> @ 2022-09-22 1:41 ` Jason Wang 0 siblings, 0 replies; 4+ messages in thread From: Jason Wang @ 2022-09-22 1:41 UTC (permalink / raw) To: Gavin Li, mst, stephen, davem, jesse.brandeburg, kuba, sridhar.samudrala, loseweigh, netdev, virtualization, virtio-dev Cc: Gavi Teitz 在 2022/9/14 22:49, Gavin Li 写道: > Currently add_recvbuf_big() allocates MAX_SKB_FRAGS segments for big > packets even when GUEST_* offloads are not present on the device. > However, if guest GSO is not supported, it would be sufficient to > allocate segments to cover just up the MTU size and no further. > Allocating the maximum amount of segments results in a large waste of > buffer space in the queue, which limits the number of packets that can > be buffered and can result in reduced performance. > > Therefore, if guest GSO is not supported, use the MTU to calculate the > optimal amount of segments required. > > Below is the iperf TCP test results over a Mellanox NIC, using vDPA for > 1 VQ, queue size 1024, before and after the change, with the iperf > server running over the virtio-net interface. > > MTU(Bytes)/Bandwidth (Gbit/s) > Before After > 1500 22.5 22.4 > 9000 12.8 25.9 > > And result of queue size 256. > MTU(Bytes)/Bandwidth (Gbit/s) > Before After > 9000 2.15 11.9 > > With this patch no degradation is observed with multiple below tests and > feature bit combinations. Results are summarized below for q depth of > 1024. Interface MTU is 1500 if MTU feature is disabled. MTU is set to 9000 > in other tests. > > Features/ Bandwidth (Gbit/s) > Before After > mtu off 20.1 20.2 > mtu/indirect on 17.4 17.3 > mtu/indirect/packed on 17.2 17.2 > > Signed-off-by: Gavin Li <gavinl@nvidia.com> > Reviewed-by: Gavi Teitz <gavi@nvidia.com> > Reviewed-by: Parav Pandit <parav@nvidia.com> > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> > Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com> Acked-by: Jason Wang <jasowang@redhat.com> > --- > changelog: > v5->v6 > - Addressed comments from Jason and Michael S. Tsirkin > - Remove wrong commit log description > - Rename virtnet_set_big_packets_fields with virtnet_set_big_packets > - Add more test results for different feature combinations > v4->v5 > - Addressed comments from Michael S. Tsirkin > - Improve commit message > v3->v4 > - Addressed comments from Si-Wei > - Rename big_packets_sg_num with big_packets_num_skbfrags > v2->v3 > - Addressed comments from Si-Wei > - Simplify the condition check to enable the optimization > v1->v2 > - Addressed comments from Jason, Michael, Si-Wei. > - Remove the flag of guest GSO support, set sg_num for big packets and > use it directly > - Recalculate sg_num for big packets in virtnet_set_guest_offloads > - Replace the round up algorithm with DIV_ROUND_UP > --- > drivers/net/virtio_net.c | 37 ++++++++++++++++++++++++------------- > 1 file changed, 24 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index f54c7182758f..7106932c6f88 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -225,6 +225,9 @@ struct virtnet_info { > /* I like... big packets and I cannot lie! */ > bool big_packets; > > + /* number of sg entries allocated for big packets */ > + unsigned int big_packets_num_skbfrags; > + > /* Host will merge rx buffers for big packets (shake it! shake it!) */ > bool mergeable_rx_bufs; > > @@ -1331,10 +1334,10 @@ static int add_recvbuf_big(struct virtnet_info *vi, struct receive_queue *rq, > char *p; > int i, err, offset; > > - sg_init_table(rq->sg, MAX_SKB_FRAGS + 2); > + sg_init_table(rq->sg, vi->big_packets_num_skbfrags + 2); > > - /* page in rq->sg[MAX_SKB_FRAGS + 1] is list tail */ > - for (i = MAX_SKB_FRAGS + 1; i > 1; --i) { > + /* page in rq->sg[vi->big_packets_num_skbfrags + 1] is list tail */ > + for (i = vi->big_packets_num_skbfrags + 1; i > 1; --i) { > first = get_a_page(rq, gfp); > if (!first) { > if (list) > @@ -1365,7 +1368,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, struct receive_queue *rq, > > /* chain first in list head */ > first->private = (unsigned long)list; > - err = virtqueue_add_inbuf(rq->vq, rq->sg, MAX_SKB_FRAGS + 2, > + err = virtqueue_add_inbuf(rq->vq, rq->sg, vi->big_packets_num_skbfrags + 2, > first, gfp); > if (err < 0) > give_pages(rq, first); > @@ -3690,13 +3693,27 @@ static bool virtnet_check_guest_gso(const struct virtnet_info *vi) > virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO); > } > > +static void virtnet_set_big_packets(struct virtnet_info *vi, const int mtu) > +{ > + bool guest_gso = virtnet_check_guest_gso(vi); > + > + /* If device can receive ANY guest GSO packets, regardless of mtu, > + * allocate packets of maximum size, otherwise limit it to only > + * mtu size worth only. > + */ > + if (mtu > ETH_DATA_LEN || guest_gso) { > + vi->big_packets = true; > + vi->big_packets_num_skbfrags = guest_gso ? MAX_SKB_FRAGS : DIV_ROUND_UP(mtu, PAGE_SIZE); > + } > +} > + > static int virtnet_probe(struct virtio_device *vdev) > { > int i, err = -ENOMEM; > struct net_device *dev; > struct virtnet_info *vi; > u16 max_queue_pairs; > - int mtu; > + int mtu = 0; > > /* Find if host supports multiqueue/rss virtio_net device */ > max_queue_pairs = 1; > @@ -3784,10 +3801,6 @@ static int virtnet_probe(struct virtio_device *vdev) > INIT_WORK(&vi->config_work, virtnet_config_changed_work); > spin_lock_init(&vi->refill_lock); > > - /* If we can receive ANY GSO packets, we must allocate large ones. */ > - if (virtnet_check_guest_gso(vi)) > - vi->big_packets = true; > - > if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) > vi->mergeable_rx_bufs = true; > > @@ -3853,12 +3866,10 @@ static int virtnet_probe(struct virtio_device *vdev) > > dev->mtu = mtu; > dev->max_mtu = mtu; > - > - /* TODO: size buffers correctly in this case. */ > - if (dev->mtu > ETH_DATA_LEN) > - vi->big_packets = true; > } > > + virtnet_set_big_packets(vi, mtu); > + > if (vi->any_header_sg) > dev->needed_headroom = vi->hdr_len; > _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v6 0/2] Improve virtio performance for 9k mtu [not found] <20220914144911.56422-1-gavinl@nvidia.com> [not found] ` <20220914144911.56422-2-gavinl@nvidia.com> [not found] ` <20220914144911.56422-3-gavinl@nvidia.com> @ 2022-09-29 7:00 ` Michael S. Tsirkin [not found] ` <68934c1a-6c75-f410-2c29-1a7edc97aeb9@nvidia.com> 3 siblings, 0 replies; 4+ messages in thread From: Michael S. Tsirkin @ 2022-09-29 7:00 UTC (permalink / raw) To: Gavin Li Cc: virtio-dev, sridhar.samudrala, jesse.brandeburg, virtualization, stephen, loseweigh, netdev, kuba, davem On Wed, Sep 14, 2022 at 05:49:09PM +0300, Gavin Li wrote: > This small series contains two patches that improves virtio netdevice > performance for 9K mtu when GRO/ guest TSO is disabled. > > Gavin Li (2): > virtio-net: introduce and use helper function for guest gso support > checks series: Acked-by: Michael S. Tsirkin <mst@redhat.com> this is net-next material > --- > changelog: > v4->v5 > - Addressed comments from Michael S. Tsirkin > - Remove unnecessary () in return clause > v1->v2 > - Add new patch > --- > virtio-net: use mtu size as buffer length for big packets > --- > changelog: > v5->v6 > - Addressed comments from Jason and Michael S. Tsirkin > - Remove wrong commit log description > - Rename virtnet_set_big_packets_fields with virtnet_set_big_packets > - Add more test results for different feature combinations > v4->v5 > - Addressed comments from Michael S. Tsirkin > - Improve commit message > v3->v4 > - Addressed comments from Si-Wei > - Rename big_packets_sg_num with big_packets_num_skbfrags > v2->v3 > - Addressed comments from Si-Wei > - Simplify the condition check to enable the optimization > v1->v2 > - Addressed comments from Jason, Michael, Si-Wei. > - Remove the flag of guest GSO support, set sg_num for big packets and > use it directly > - Recalculate sg_num for big packets in virtnet_set_guest_offloads > - Replace the round up algorithm with DIV_ROUND_UP > --- > > drivers/net/virtio_net.c | 48 ++++++++++++++++++++++++++-------------- > 1 file changed, 32 insertions(+), 16 deletions(-) > > -- > 2.31.1 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <68934c1a-6c75-f410-2c29-1a7edc97aeb9@nvidia.com>]
* Re: [virtio-dev] [PATCH v6 0/2] Improve virtio performance for 9k mtu [not found] ` <68934c1a-6c75-f410-2c29-1a7edc97aeb9@nvidia.com> @ 2022-09-29 7:01 ` Michael S. Tsirkin 0 siblings, 0 replies; 4+ messages in thread From: Michael S. Tsirkin @ 2022-09-29 7:01 UTC (permalink / raw) To: Gavin Li Cc: virtio-dev, sridhar.samudrala, jesse.brandeburg, virtualization, stephen, loseweigh, netdev, kuba, davem On Thu, Sep 29, 2022 at 02:50:00PM +0800, Gavin Li wrote: > > On 9/14/2022 10:49 PM, Gavin Li wrote: > > External email: Use caution opening links or attachments > > > > > > This small series contains two patches that improves virtio netdevice > > performance for 9K mtu when GRO/ guest TSO is disabled. > > > > Gavin Li (2): > > virtio-net: introduce and use helper function for guest gso support > > checks > > --- > > changelog: > > v4->v5 > > - Addressed comments from Michael S. Tsirkin > > - Remove unnecessary () in return clause > > v1->v2 > > - Add new patch > > --- > > virtio-net: use mtu size as buffer length for big packets > > --- > > changelog: > > v5->v6 > > - Addressed comments from Jason and Michael S. Tsirkin > > - Remove wrong commit log description > > - Rename virtnet_set_big_packets_fields with virtnet_set_big_packets > > - Add more test results for different feature combinations > > v4->v5 > > - Addressed comments from Michael S. Tsirkin > > - Improve commit message > > v3->v4 > > - Addressed comments from Si-Wei > > - Rename big_packets_sg_num with big_packets_num_skbfrags > > v2->v3 > > - Addressed comments from Si-Wei > > - Simplify the condition check to enable the optimization > > v1->v2 > > - Addressed comments from Jason, Michael, Si-Wei. > > - Remove the flag of guest GSO support, set sg_num for big packets and > > use it directly > > - Recalculate sg_num for big packets in virtnet_set_guest_offloads > > - Replace the round up algorithm with DIV_ROUND_UP > > --- > > > > drivers/net/virtio_net.c | 48 ++++++++++++++++++++++++++-------------- > > 1 file changed, 32 insertions(+), 16 deletions(-) > > > > -- > > 2.31.1 > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org > Did you get a chance to pull these short series? Not in net-next yet for some reason, I was hoping it will get some testing here. I'll put it in my tree for next for now so it gets tested. Thanks! _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-29 7:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220914144911.56422-1-gavinl@nvidia.com>
[not found] ` <20220914144911.56422-2-gavinl@nvidia.com>
2022-09-22 1:39 ` [PATCH v6 1/2] virtio-net: introduce and use helper function for guest gso support checks Jason Wang
[not found] ` <20220914144911.56422-3-gavinl@nvidia.com>
2022-09-22 1:41 ` [PATCH v6 2/2] virtio-net: use mtu size as buffer length for big packets Jason Wang
2022-09-29 7:00 ` [PATCH v6 0/2] Improve virtio performance for 9k mtu Michael S. Tsirkin
[not found] ` <68934c1a-6c75-f410-2c29-1a7edc97aeb9@nvidia.com>
2022-09-29 7:01 ` [virtio-dev] " Michael S. Tsirkin
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).