All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Wu <wu.wubin@huawei.com>
To: mst@redhat.com, Paolo Bonzini <pbonzini@redhat.com>,
	Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org,
	"Wangting (Kathy)" <kathy.wangting@huawei.com>,
	subo <subo7@huawei.com>,
	wu.wubin@huawei.com
Subject: [Qemu-devel] Does the event idx mechanism in virtio work in the correct way?
Date: Wed, 15 Oct 2014 14:09:29 +0800	[thread overview]
Message-ID: <543E0F99.3060705@huawei.com> (raw)

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

             reply	other threads:[~2014-10-15  6:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15  6:09 Bin Wu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-10-16  0:46 [Qemu-devel] Does the event idx mechanism in virtio work in the correct way? Bin Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543E0F99.3060705@huawei.com \
    --to=wu.wubin@huawei.com \
    --cc=famz@redhat.com \
    --cc=kathy.wangting@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=subo7@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.