From patchwork Fri Jul 29 22:55:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirley Ma X-Patchwork-Id: 1021942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6TMv54K023179 for ; Fri, 29 Jul 2011 22:57:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753161Ab1G2W44 (ORCPT ); Fri, 29 Jul 2011 18:56:56 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:56588 "EHLO e3.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838Ab1G2W4z (ORCPT ); Fri, 29 Jul 2011 18:56:55 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6TMX93b030230; Fri, 29 Jul 2011 18:33:09 -0400 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6TMtbmn151940; Fri, 29 Jul 2011 18:55:38 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6TMtbne020757; Fri, 29 Jul 2011 16:55:37 -0600 Received: from [9.65.234.110] (sig-9-65-234-110.mts.ibm.com [9.65.234.110]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6TMtXYN020640; Fri, 29 Jul 2011 16:55:33 -0600 Subject: Re: [PATCH RFC net-next] virtio_net: refill buffer right after being used From: Shirley Ma To: Rusty Russell Cc: mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.osdl.org, netdev@vger.kernel.org In-Reply-To: <1311979448.24300.28.camel@localhost.localdomain> References: <1311979448.24300.28.camel@localhost.localdomain> Date: Fri, 29 Jul 2011 15:55:31 -0700 Message-ID: <1311980131.24300.30.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Jul 2011 22:57:05 +0000 (UTC) Resubmit it with a typo fix. Signed-off-by: Shirley Ma --- -- 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 diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 0c7321c..c8201d4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -429,6 +429,22 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp) return err; } +static int fill_one(struct virtnet_info *vi, gfp_t gfp) +{ + int err; + + if (vi->mergeable_rx_bufs) + err = add_recvbuf_mergeable(vi, gfp); + else if (vi->big_packets) + err = add_recvbuf_big(vi, gfp); + else + err = add_recvbuf_small(vi, gfp); + + if (err >= 0) + ++vi->num; + return err; +} + /* Returns false if we couldn't fill entirely (OOM). */ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) { @@ -436,17 +452,10 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) bool oom; do { - if (vi->mergeable_rx_bufs) - err = add_recvbuf_mergeable(vi, gfp); - else if (vi->big_packets) - err = add_recvbuf_big(vi, gfp); - else - err = add_recvbuf_small(vi, gfp); - + err = fill_one(vi, gfp); oom = err == -ENOMEM; if (err < 0) break; - ++vi->num; } while (err > 0); if (unlikely(vi->num > vi->max)) vi->max = vi->num; @@ -506,13 +515,13 @@ again: receive_buf(vi->dev, buf, len); --vi->num; received++; - } - - if (vi->num < vi->max / 2) { - if (!try_fill_recv(vi, GFP_ATOMIC)) + if (fill_one(vi, GFP_ATOMIC) < 0) schedule_delayed_work(&vi->refill, 0); } + /* notify buffers are refilled */ + virtqueue_kick(vi->rvq); + /* Out of packets? */ if (received < budget) { napi_complete(napi);