qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Steve Dobbelstein <steved@us.ibm.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org,
	Khoa Huynh <khoa@us.ibm.com>, Sridhar Samudrala <sri@us.ibm.com>
Subject: [Qemu-devel] Re: [PATCH] virtio: Use ioeventfd for virtqueue notify
Date: Mon, 25 Oct 2010 14:25:05 +0100	[thread overview]
Message-ID: <20101025132458.GA2886@stefan-thinkpad.transitives.com> (raw)
In-Reply-To: <20101019133330.GB18341@redhat.com>

On Tue, Oct 19, 2010 at 03:33:41PM +0200, Michael S. Tsirkin wrote:
> My main concern is with the fact that we add more state
> in notifiers that can easily get out of sync with users.
> If we absolutely need this state, let's try to at least
> document the state machine, and make the API
> for state transitions more transparent.

I'll try to describe how it works.  If you're happy with the design in
principle then I can rework the code.  Otherwise we can think about a
different design.

The goal is to use ioeventfd instead of the synchronous pio emulation
path that userspace virtqueues use today.  Both virtio-blk and
virtio-net increase performance with this approach because it does not
block the vcpu from executing guest code while the I/O operation is
initiated.

We want to automatically create an event notifier and setup ioeventfd
for each initialized virtqueue.

Vhost already uses ioeventfd so it is important not to interfere with
devices that have enabled vhost.  If vhost is enabled, then the device's
virtqueues are off-limits and should not be tampered with.

Furthermore, older kernels limit you to 6 ioeventfds per guest.  On such
systems it is risky to automatically use ioeventfd for userspace
virtqueues, since that could take a precious ioeventfd away from another
virtio device using vhost.  Existing guest configurations would break so
it is simplest to avoid using ioeventfd for userspace virtqueues on such
hosts.

The design adds logic into hw/virtio.c to automatically use ioeventfd
for userspace virtqueues.  Specific virtio devices like blk and net
require no modification.  The logic sits below the set_host_notifier()
function that vhost uses.

This design stays in sync because it speaks two interfaces that allow it
to accurately track whether or not to use ioeventfd:
1. virtio_set_host_notifier() is used by vhost.  When vhost enables the
   host notifier we stay out of the way.
2. virtio_reset()/virtio_set_status()/virtio_load() define the device
   life-cycle and transition the state machine appropriately.  Migration
   is supported.

Here is the state machine that tracks a virtqueue:

                 assigned
             ^ /          \ ^
         e. / / c.      g. \ \ b.
           / /              \ \
          / v       f.       v \               a.
 offlimits   ---------------> deassigned <-- start
             <---------------
                    d.

a. The virtqueue starts deassigned with no ioeventfd.

b. When the device status becomes VIRTIO_CONFIG_S_DRIVER_OK we try to
assign an ioeventfd to each virtqueue, except if the 6 ioeventfd
limitation is present.

c, d. The virtqueue becomes offlimits if vhost enables the host notifier.

e. The ioeventfd becomes assigned again when the host notifier is disabled by vhost.
f. Except when the 6 ioeventfd limitation is present, then the ioeventfd
becomes unassigned because we want to avoid using ioeventfd.

g. When the device is reset its virtqueues become deassigned again.

Does this make sense?

Stefan

  reply	other threads:[~2010-10-25 16:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 14:01 [Qemu-devel] [PATCH] virtio: Use ioeventfd for virtqueue notify Stefan Hajnoczi
2010-10-03 11:01 ` [Qemu-devel] " Avi Kivity
2010-10-03 13:51   ` Michael S. Tsirkin
2010-10-03 14:21     ` Avi Kivity
2010-10-03 14:28       ` Michael S. Tsirkin
2010-10-04  1:18         ` Anthony Liguori
2010-10-04  8:04           ` Avi Kivity
2010-10-04 14:01             ` Anthony Liguori
2010-10-04 16:12               ` Michael S. Tsirkin
2010-10-04 16:20                 ` Anthony Liguori
2010-10-04 16:25                   ` Michael S. Tsirkin
2010-10-04 14:30   ` Stefan Hajnoczi
2010-10-05 11:00   ` rukhsana ansari
2010-10-05 11:58     ` Avi Kivity
2010-10-19 13:07 ` Stefan Hajnoczi
2010-10-19 13:12   ` Anthony Liguori
2010-10-19 13:35     ` Michael S. Tsirkin
2010-10-19 13:44       ` Stefan Hajnoczi
2010-10-19 13:43         ` Michael S. Tsirkin
2010-11-10 14:52           ` Stefan Hajnoczi
2010-10-19 13:33 ` Michael S. Tsirkin
2010-10-25 13:25   ` Stefan Hajnoczi [this message]
2010-10-25 15:01   ` Stefan Hajnoczi

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=20101025132458.GA2886@stefan-thinkpad.transitives.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=khoa@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sri@us.ibm.com \
    --cc=steved@us.ibm.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 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).