From patchwork Tue Feb 2 21:48:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirley Ma X-Patchwork-Id: 76526 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o12Ln9ED013598 for ; Tue, 2 Feb 2010 21:49:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756826Ab0BBVtH (ORCPT ); Tue, 2 Feb 2010 16:49:07 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:58959 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756631Ab0BBVtE (ORCPT ); Tue, 2 Feb 2010 16:49:04 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o12LgqB4028914 for ; Tue, 2 Feb 2010 14:42:52 -0700 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id o12Lmux8183068 for ; Tue, 2 Feb 2010 14:48:58 -0700 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o12Lp41f019290 for ; Tue, 2 Feb 2010 14:51:04 -0700 Received: from [9.47.18.148] (dyn9047018148.beaverton.ibm.com [9.47.18.148]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o12Lp3bL019273; Tue, 2 Feb 2010 14:51:03 -0700 Subject: [PATCH 1/1 net-next] virtio_net: remove send queue From: Shirley Ma To: Rusty Russell , "Michael S. Tsirkin Cc: kvm@vger.kernel.org In-Reply-To: <201001292350.04544.rusty@rustcorp.com.au> References: <201001292346.43675.rusty@rustcorp.com.au> <201001292349.05360.rusty@rustcorp.com.au> <201001292350.04544.rusty@rustcorp.com.au> Date: Tue, 02 Feb 2010 13:48:51 -0800 Message-ID: <1265147331.672.20.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.28.2 (2.28.2-1.fc12) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 21:49:10 +0000 (UTC) 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);