qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Does the event idx mechanism in virtio work in the correct


From: Bin Wu
Subject: [Qemu-devel] Does the event idx mechanism in virtio work in the correct way?
Date: Thu, 16 Oct 2014 08:46:56 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]