[PATCH] virtio_net: Check for room in the vq before adding buffer

Amit Shah amit.shah at redhat.com
Thu Aug 27 04:18:12 PDT 2009


On (Thu) Aug 27 2009 [20:36:07], Rusty Russell wrote:
> > 
> > I'm missing something though: the value of 'num' changes in the loop and
> > the value of num when it will be compared will just have been used by
> > add_buf. The next iteration of the loop will probably use a different
> > value (-- from just reading the code, not going over the cases in which
> > this function is called).
> 
> Here's the code:
> 
> 		num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
> 		skb_queue_head(&vi->recv, skb);
> 
> 		err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
> 		if (err < 0) {
> 			skb_unlink(skb, &vi->recv);
> 			trim_pages(vi, skb);
> 			kfree_skb(skb);
> 			break;
> 		}
> 		vi->num++;
> 	} while (err >= num);
> 
> Now, it turns out that we always allocate packets of the same size.

OK; works since the packet size is the same.

> So the number of descriptors required by the next packet will be the same as
> for this packet.
> 
> Clear?

Thanks!

> Rusty.

		Amit


More information about the Virtualization mailing list