qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Does the event idx mechanism in virtio work in the correct way?
@ 2014-10-15  6:09 Bin Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Wu @ 2014-10-15  6:09 UTC (permalink / raw)
  To: mst, Paolo Bonzini, Fam Zheng, qemu-devel, Wangting (Kathy), subo,
	wu.wubin

Hi,
	The event idx in virtio is an effective way to reduce the number of interrupts 
and exits of the guest. When the guest puts an request into the virtio ring, it 
doesn't exit immediately to inform the backend. Instead, the guest checks the 
"avail" event idx to determine the notification. For example, assume that the 
guest already puts five requests in the ring and the backend gets two of these 
requests, then the "avail" event idx should be two. Now the guest puts another 
request into the ring. It checks the "avail" event idx and finds the event idx 
(equals to 2) is less than the number of available requests (equals to 6), so it 
will not notify the backend to work. The backend works in a loop to get the 
request from the ring until the ring is empty or all requests have been taken.
	However, I find some code doesn't work in the way I thought:

int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
{
	...
	i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
     	if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) {
         	vring_avail_event(vq, vring_avail_idx(vq));
     	}
	...
}

In the sentence "vring_avail_event(vq, vring_avail_idx(vq));", I think the 
"avail" event idx should equal to the number of requests have been 
taken(vq->last_avail_idx), not the number of all available requests 
(vring_avail_idx(vq)). Is there any special consideration or do I just 
misunderstand the event idx?

thanks

Bin Wu

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Qemu-devel] Does the event idx mechanism in virtio work in the correct way?
@ 2014-10-16  0:46 Bin Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Wu @ 2014-10-16  0:46 UTC (permalink / raw)
  To: qemu-devel, mst, Paolo Bonzini, Fam Zheng

Hi,
The event idx in virtio is an effective way to reduce the number of interrupts
and exits of the guest. When the guest puts an request into the virtio ring, it
doesn't exit immediately to inform the backend. Instead, the guest checks the
"avail" event idx to determine the notification. For example, assume that the
guest already puts five requests in the ring and the backend gets two of these
requests, then the "avail" event idx should be two. Now the guest puts another
request into the ring. It checks the "avail" event idx and finds the event idx
(equals to 2) is less than the number of available requests (equals to 6), so it
will not notify the backend to work. The backend works in a loop to get the
request from the ring until the ring is empty or all requests have been taken.

However, I find some code doesn't work in the way I thought:

int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
{
    ...
    i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
        if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) {
            vring_avail_event(vq, vring_avail_idx(vq));
        }
    ...
}

In the statement"vring_avail_event(vq, vring_avail_idx(vq));", I think the
"avail" event idx should equal to the number of requests have been
taken(vq->last_avail_idx), not the number of all available requests
(vring_avail_idx(vq)). Is there any special consideration or do I just
misunderstand the event idx?

thanks
-- 
Bin Wu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-16  0:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16  0:46 [Qemu-devel] Does the event idx mechanism in virtio work in the correct way? Bin Wu
  -- strict thread matches above, loose matches on Subject: below --
2014-10-15  6:09 Bin Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).