diff options
| author | Amit Shah <amit.shah@redhat.com> | 2009-08-26 14:58:28 +0530 |
|---|---|---|
| committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2009-09-02 10:29:10 +1000 |
| commit | 1bd0e3809cd71567bb19059bb4818a9324771a40 (patch) | |
| tree | 6b5931ad188dfa19f57bde1a4d9f01de87e492b5 | |
| parent | 422c63d9e6e896b0709610b0b792b3b3541a7182 (diff) | |
| download | linux-next-1bd0e3809cd71567bb19059bb4818a9324771a40.tar.gz | |
virtio_net: Check for room in the vq before adding buffer
Notice: this object is not reachable from any branch.
Saves us one cycle of alloc-add-free if the queue was full.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (modified)
Notice: this object is not reachable from any branch.
| -rw-r--r-- | drivers/net/virtio_net.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9ccc0fe376d9f..e49491e95d0e9 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -280,7 +280,7 @@ static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp) bool oom = false; sg_init_table(sg, 2+MAX_SKB_FRAGS); - for (;;) { + do { struct skb_vnet_hdr *hdr; skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN); @@ -323,7 +323,7 @@ static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp) break; } vi->num++; - } + } while (err >= num); if (unlikely(vi->num > vi->max)) vi->max = vi->num; vi->rvq->vq_ops->kick(vi->rvq); @@ -341,7 +341,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) if (!vi->mergeable_rx_bufs) return try_fill_recv_maxbufs(vi, gfp); - for (;;) { + do { skb_frag_t *f; skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN); @@ -375,7 +375,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) break; } vi->num++; - } + } while (err > 0); if (unlikely(vi->num > vi->max)) vi->max = vi->num; vi->rvq->vq_ops->kick(vi->rvq); |
