* [PATCH 1/1 net-next] virtio_net: remove send queue [not found] ` <201001292350.04544.rusty@rustcorp.com.au> @ 2010-02-02 21:48 ` Shirley Ma 2010-02-02 21:52 ` [PATCH 0/1 " Shirley Ma ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Shirley Ma @ 2010-02-02 21:48 UTC (permalink / raw) To: Rusty Russell, "Michael S. Tsirkin <mst", Rusty Russell; +Cc: kvm Use detach buffers API in virtio to free unused buffers in send queue when shutting down virtio_net to avoid maintaining skb link list for each transmit packet. Signed-off-by: Shirley Ma <xma@us.ibm.com> --- drivers/net/virtio_net.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9d8984a..8069c08 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -56,9 +56,6 @@ struct virtnet_info /* Host will merge rx buffers for big packets (shake it! shake it!) */ bool mergeable_rx_bufs; - /* Send queue. */ - struct sk_buff_head send; - /* Work struct for refilling if we run low on memory. */ struct delayed_work refill; @@ -505,7 +502,6 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { pr_debug("Sent skb %p\n", skb); - __skb_unlink(skb, &vi->send); vi->dev->stats.tx_bytes += skb->len; vi->dev->stats.tx_packets++; tot_sgs += skb_vnet_hdr(skb)->num_sg; @@ -588,15 +584,6 @@ again: } vi->svq->vq_ops->kick(vi->svq); - /* - * Put new one in send queue. You'd expect we'd need this before - * xmit_skb calls add_buf(), since the callback can be triggered - * immediately after that. But since the callback just triggers - * another call back here, normal network xmit locking prevents the - * race. - */ - __skb_queue_head(&vi->send, skb); - /* Don't wait up for transmitted skbs to be freed. */ skb_orphan(skb); nf_reset(skb); @@ -977,9 +964,6 @@ static int virtnet_probe(struct virtio_device *vdev) dev->features |= NETIF_F_HW_VLAN_FILTER; } - /* Initialize our empty send queue. */ - skb_queue_head_init(&vi->send); - err = register_netdev(dev); if (err) { pr_debug("virtio_net: registering device failed\n"); @@ -1016,6 +1000,12 @@ static void free_unused_bufs(struct virtnet_info *vi) { void *buf; while (1) { + buf = vi->svq->vq_ops->detach_unused_buf(vi->svq); + if (!buf) + break; + dev_kfree_skb(buf); + } + while (1) { buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq); if (!buf) break; @@ -1035,11 +1025,11 @@ static void __devexit virtnet_remove(struct virtio_device *vdev) /* Stop all the virtqueues. */ vdev->config->reset(vdev); - /* Free our skbs in send queue, if any. */ - __skb_queue_purge(&vi->send); unregister_netdev(vi->dev); cancel_delayed_work_sync(&vi->refill); + + /* Free unused buffers in both send and recv, if any. */ free_unused_bufs(vi); vdev->config->del_vqs(vi->vdev); ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 0/1 net-next] virtio_net: remove send queue 2010-02-02 21:48 ` [PATCH 1/1 net-next] virtio_net: remove send queue Shirley Ma @ 2010-02-02 21:52 ` Shirley Ma 2010-02-03 10:03 ` [PATCH 1/1 " Michael S. Tsirkin 2010-02-08 1:41 ` Rusty Russell 2 siblings, 0 replies; 4+ messages in thread From: Shirley Ma @ 2010-02-02 21:52 UTC (permalink / raw) To: Rusty Russell; +Cc: Michael S.Tsirkin, kvm This patch is built on top of net-next + defer skb patch for virtio_net. The patch has been tested and some performance has been gained by removing skb link & unlink for each packet in send queue. thanks Shirley ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1 net-next] virtio_net: remove send queue 2010-02-02 21:48 ` [PATCH 1/1 net-next] virtio_net: remove send queue Shirley Ma 2010-02-02 21:52 ` [PATCH 0/1 " Shirley Ma @ 2010-02-03 10:03 ` Michael S. Tsirkin 2010-02-08 1:41 ` Rusty Russell 2 siblings, 0 replies; 4+ messages in thread From: Michael S. Tsirkin @ 2010-02-03 10:03 UTC (permalink / raw) To: Shirley Ma; +Cc: Rusty Russell, kvm On Tue, Feb 02, 2010 at 01:48:51PM -0800, Shirley Ma wrote: > Use detach buffers API in virtio to free unused buffers in send queue when shutting down > virtio_net to avoid maintaining skb link list for each transmit packet. > > Signed-off-by: Shirley Ma <xma@us.ibm.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> > --- > drivers/net/virtio_net.c | 26 ++++++++------------------ > 1 files changed, 8 insertions(+), 18 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 9d8984a..8069c08 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -56,9 +56,6 @@ struct virtnet_info > /* Host will merge rx buffers for big packets (shake it! shake it!) */ > bool mergeable_rx_bufs; > > - /* Send queue. */ > - struct sk_buff_head send; > - > /* Work struct for refilling if we run low on memory. */ > struct delayed_work refill; > > @@ -505,7 +502,6 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) > > while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { > pr_debug("Sent skb %p\n", skb); > - __skb_unlink(skb, &vi->send); > vi->dev->stats.tx_bytes += skb->len; > vi->dev->stats.tx_packets++; > tot_sgs += skb_vnet_hdr(skb)->num_sg; > @@ -588,15 +584,6 @@ again: > } > vi->svq->vq_ops->kick(vi->svq); > > - /* > - * Put new one in send queue. You'd expect we'd need this before > - * xmit_skb calls add_buf(), since the callback can be triggered > - * immediately after that. But since the callback just triggers > - * another call back here, normal network xmit locking prevents the > - * race. > - */ > - __skb_queue_head(&vi->send, skb); > - > /* Don't wait up for transmitted skbs to be freed. */ > skb_orphan(skb); > nf_reset(skb); > @@ -977,9 +964,6 @@ static int virtnet_probe(struct virtio_device *vdev) > dev->features |= NETIF_F_HW_VLAN_FILTER; > } > > - /* Initialize our empty send queue. */ > - skb_queue_head_init(&vi->send); > - > err = register_netdev(dev); > if (err) { > pr_debug("virtio_net: registering device failed\n"); > @@ -1016,6 +1000,12 @@ static void free_unused_bufs(struct virtnet_info *vi) > { > void *buf; > while (1) { > + buf = vi->svq->vq_ops->detach_unused_buf(vi->svq); > + if (!buf) > + break; > + dev_kfree_skb(buf); > + } > + while (1) { > buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq); > if (!buf) > break; > @@ -1035,11 +1025,11 @@ static void __devexit virtnet_remove(struct virtio_device *vdev) > /* Stop all the virtqueues. */ > vdev->config->reset(vdev); > > - /* Free our skbs in send queue, if any. */ > - __skb_queue_purge(&vi->send); > > unregister_netdev(vi->dev); > cancel_delayed_work_sync(&vi->refill); > + > + /* Free unused buffers in both send and recv, if any. */ > free_unused_bufs(vi); > > vdev->config->del_vqs(vi->vdev); > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1 net-next] virtio_net: remove send queue 2010-02-02 21:48 ` [PATCH 1/1 net-next] virtio_net: remove send queue Shirley Ma 2010-02-02 21:52 ` [PATCH 0/1 " Shirley Ma 2010-02-03 10:03 ` [PATCH 1/1 " Michael S. Tsirkin @ 2010-02-08 1:41 ` Rusty Russell 2 siblings, 0 replies; 4+ messages in thread From: Rusty Russell @ 2010-02-08 1:41 UTC (permalink / raw) To: Shirley Ma; +Cc: "Michael S. Tsirkin <mst", kvm On Wed, 3 Feb 2010 08:18:51 am Shirley Ma wrote: > Use detach buffers API in virtio to free unused buffers in send queue when shutting down > virtio_net to avoid maintaining skb link list for each transmit packet. > > Signed-off-by: Shirley Ma <xma@us.ibm.com> Hi Shirley, Nice cleanup. Please cc: netdev@vger.kernel.org for net patches... Your comment could be slightly enhanced to indicate that the API is new, eg; Now we have a virtio detach API (in commit XXXXXXXXXX), we don't need to track xmit skbs in the driver. Acked-by: Rusty Russell <rusty@rustcorp.com.au> Thanks! Rusty. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-08 1:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <201001292346.43675.rusty@rustcorp.com.au>
[not found] ` <201001292349.05360.rusty@rustcorp.com.au>
[not found] ` <201001292350.04544.rusty@rustcorp.com.au>
2010-02-02 21:48 ` [PATCH 1/1 net-next] virtio_net: remove send queue Shirley Ma
2010-02-02 21:52 ` [PATCH 0/1 " Shirley Ma
2010-02-03 10:03 ` [PATCH 1/1 " Michael S. Tsirkin
2010-02-08 1:41 ` Rusty Russell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox