RE: A question about vring operation

From: Wang, Wei W
Date: Fri Aug 28 2015 - 01:25:50 EST



On 24/07/2015 21:36, Michael S. Tsirkin wrote:
>On Thu, Aug 27, 2015 at 01:18:47AM +0000, Wang, Wei W wrote:
> Hi all,
>
>
>
> I have a question about the vring_avail:
>
> It only includes an idx (equivalent to the ring tail), which is used
> by the frontend (virtio_net) to fill bufs. The backend (e.g.
> vhost_net) maintains the ring head (last_avail_idx) by itself. The
> frontend checks if the ring is full or empty via a counter (vq->num_free).
>
> My question is why canât we include the ring head in the vring_avail
> struct, so that the vq->num_free is not needed, and the backend can
> directly use it without maintaining its own copy?
>
>
>
> Thanks,
>
> Wei
>
>
>
>I'm not sure I understand your proposal, and what it would accomplish. Write a patch, that'll make it easier to discuss.
>Also copy all relevant mailing lists, not just kvm.

Thanks Michael. I havenât got the patch ready yet. I am just wondering if it is better to have "last_avail_idx" in vhost_virtqueue moved into vring_avail.

In other regular ring operations, we usually use *head and *tail to judge if the ring is full or empty, but it seems vring_avail does not use this method in virtio_net.c (it uses a counter).

Best,
Wei