All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Iwan Budi Kusnanto <ibk@labhijau.net>,
	Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Qemu coroutine behaviour on blocking send(3)
Date: Fri, 28 Nov 2014 15:15:12 +0100	[thread overview]
Message-ID: <54788370.603@redhat.com> (raw)
In-Reply-To: <CALv1wjHKqy5R=dMeB56ga_gfvoWjhOPNTeGctuH1KWFmBRvnJA@mail.gmail.com>



On 28/11/2014 14:46, Iwan Budi Kusnanto wrote:
> On Fri, Nov 28, 2014 at 7:47 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> On Fri, Nov 28, 2014 at 01:55:00PM +0700, Iwan Budi Kusnanto wrote:
>>> I meant, does the coroutine will do yield internally when it get
>>> blocked on send(3)?
>>
>> No.  In general, QEMU will use non-blocking file descriptors so the
>> blocking case does not apply.  (You can't use blocking file descriptors
>> in an event loop without a risk of blocking the entire event loop.)
>>
>> There is qemu_co_send(), which attempts the non-blocking send(2) and
>> yields on EAGAIN.
>>
>> block/sheepdog.c and nbd.c both use this function.  It's a little ugly
>> because the caller must add/remove the socket write fd handler function
>> so that the coroutine is re-entered when the fd becomes writable again.
> 
> Thanks Stefan, it really helps.

I'll add that outgoing migration _does_ use blocking file descriptors.
But it runs in a separate thread and does not use coroutines.

Incoming migration, instead, uses coroutines, because it is not as
performance-intensive as outgoing migration and it's a bit easier to not
worry about thread-safety.

Paolo

      reply	other threads:[~2014-11-28 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28  6:50 [Qemu-devel] Qemu coroutine behaviour on blocking send(3) Iwan Budi Kusnanto
2014-11-28  6:55 ` Iwan Budi Kusnanto
2014-11-28 12:47   ` Stefan Hajnoczi
2014-11-28 13:46     ` Iwan Budi Kusnanto
2014-11-28 14:15       ` Paolo Bonzini [this message]

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=54788370.603@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ibk@labhijau.net \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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.