qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Charls D. Chap" <chapcharls@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] From virtio_kick until VM-exit?
Date: Wed, 27 Jul 2016 14:46:18 +0100	[thread overview]
Message-ID: <CAJSP0QUZ6MaaNtEmAhQsu4sUiJr9=2Z6J7WN8nDvwS3CPes+xQ@mail.gmail.com> (raw)
In-Reply-To: <CAA6eV_S620HCTiRHR+6v6Qu4dTMF+soznfR5-3sVuQqXuBKXwg@mail.gmail.com>

On Wed, Jul 27, 2016 at 2:20 PM, Charls D. Chap <chapcharls@gmail.com> wrote:
> On Wed, Jul 27, 2016 at 3:52 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>>
>> On Wed, Jul 27, 2016 at 12:19:52PM +0300, charls chap wrote:
>> > Hello All,
>> >
>> > I am new with qemu, I am trying to understand the I/O path of a synchronous
>> > I/O.
>>
>> What exactly do you mean by "synchronous I/O"?
>
> An I/O , that is associated with a device opened with O_SYNC, O_DIRECT flags,
> so that we are sure that it's going all the path down, until the
> actual write of the data to the physical device.
> That's why, i can't understand, how vcpu can continue execution,
> without waiting on a condition or sleeping.
> If vcpu is not sleeping, then it means, that vcpu didn't execute the
> kick in the guest kernel?

Review how blocking write(2) is implemented on physical hardware:

The thread inside the write(2) system call blocks.  This means the
thread scheduler knows this thread cannot make progress and instead it
runs another thread in the meantime.  Eventually the I/O request is
completed and the write(2) thread becomes runnable again.  At this
point write(2) returns.

Virtualization changes nothing about this scenario.  The virtio-blk
virtqueue notification is equivalent to writing to a hardware register
on a phyiscal storage controller (SATA, SCSI HBA, etc).  In both cases
the CPU continues executing instructions while the I/O request is
being processed.

> iothread is in control and this is the thread that will follow the
> common kernel path for the I/O submit and completion. I mean, that
> iothread, will be waiting in Host kernel, I/O wait queue,
> after the submission of I/O.

No.  Please read block/raw-posix.c to understand how I/O requests are
submitted/completed in QEMU.  Either a thread pool is used so worker
threads do the blocking preadv(2)/pwritev(2)/fdatasync(2) or Linux AIO
with eventfd is used.  In both cases IOThread or the QEMU main loop
thread are event loops that wait in ppoll(2)/epoll(2) until the
eventfd is signalled.

> In the meantime, kvm does a VM_ENTRY to where?

Read the ioeventfd code in the Linux kernel: virt/kvm/eventfd.c.

> Since, the interrupt is not completed, the return point couldn't be the
> guest interrupt handler...

...

Sorry, I don't have time to reply to all your questions and it would
require me to look up the code too.  The level of detail you are
asking for is at the code level.  In other words, you're asking people
to read the code for you.

Please read the code and think about it before sending more questions.

Stefan

  reply	other threads:[~2016-07-27 13:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAA6eV_Susgqqnoi4Gy8Ohg3RROOLq6Uuv9OZbGqBh_p_yq5kAA@mail.gmail.com>
     [not found] ` <CAJSP0QW-HLiuA6MCPEK3uKEnSty65JpTz-_b9sOmjTL8DZ4byw@mail.gmail.com>
2016-07-27  9:19   ` [Qemu-devel] From virtio_kick until VM-exit? charls chap
2016-07-27  9:51     ` Stefan Hajnoczi
2016-07-27 12:42       ` Stefan Hajnoczi
2016-07-27 12:52     ` Stefan Hajnoczi
2016-07-27 13:20       ` Charls D. Chap
2016-07-27 13:46         ` Stefan Hajnoczi [this message]
     [not found]           ` <CAA6eV_Rk38Q4-YATU7cziCcFJNjX2T2FjKYwDsCDm0dZgyrakQ@mail.gmail.com>
2016-07-30  8:35             ` Stefan Hajnoczi
2016-07-27  9:30 charls chap

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='CAJSP0QUZ6MaaNtEmAhQsu4sUiJr9=2Z6J7WN8nDvwS3CPes+xQ@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=chapcharls@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).