From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] io: make qio_channel_yield aware of AioContexts
Date: Thu, 5 Jan 2017 11:46:38 +0100 [thread overview]
Message-ID: <edf6cdd7-8839-21a9-837b-cc07cbb2e7aa@redhat.com> (raw)
In-Reply-To: <20170105102637.GD3292@redhat.com>
On 05/01/2017 11:26, Daniel P. Berrange wrote:
>>>> + if (condition == G_IO_IN) {
>>>> + ioc->read_coroutine = qemu_coroutine_self();
>>>> + } else if (condition == G_IO_OUT) {
>>>> + ioc->write_coroutine = qemu_coroutine_self();
>>>> + } else {
>>>> + abort();
>>>> + }
>>> Do we really need this to be an either/or/abort ? It looks like
>>> the qio_channel_set_fd_handlers() method is happy top have both
>>> read_coroutine & write_coroutine set.
>> The idea is that this would be called by a coroutine after a
>> recv or send that returns EAGAIN (with G_IO_IN for recv and
>> G_IO_OUT for send). If not exclusive, you'd have to check
>> for ioc->read_coroutine == ioc->write_coroutine in the handler.
>> Not a big deal, I can do it, but it adds an edge case and I
>> didn't see a use for it.
>
> Yep, it feels unlikely. Tht said, it looks similar to the case
> where you have two coroutines using the same channel, and one
> does a yield(G_IO_IN) and the other does a yield(G_IO_OUT) while
> the first is still waiting, which feels like a more plausible
> scenario that could actually happen. So perhaps we do need to
> consider it
Yes, it is possible to have both two conditions active at the same time
for two different coroutines and it does happen. As in the
set_aio_context case, NBD has G_IO_IN pretty much always active to poll
for responses---and in the meanwhile a coroutine might send a request
and activate G_IO_OUT polling. In this case, however, there would be
two qio_channel_yield calls.
The unlikely part is when a single coroutine wants to poll both conditions.
One improvement I can do here is to assert !ioc->read_coroutine if
condition is G_IO_IN and !ioc->write_coroutine if condition is G_IO_OUT.
If this is not respected, the coroutine that yielded first would never
be called back again!
In any case, I'm happy that overall the API and the implementation look
sane to you.
Paolo
next prev parent reply other threads:[~2017-01-05 10:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-23 18:26 [Qemu-devel] [RFC PATCH 0/3] io/nbd: AioContext support Paolo Bonzini
2016-12-23 18:26 ` [Qemu-devel] [PATCH 1/3] io: add methods to set I/O handlers on AioContext Paolo Bonzini
2017-01-04 16:45 ` Eric Blake
2017-01-04 16:56 ` Paolo Bonzini
2017-01-04 17:14 ` Daniel P. Berrange
2016-12-23 18:26 ` [Qemu-devel] [PATCH 2/3] io: make qio_channel_yield aware of AioContexts Paolo Bonzini
2017-01-04 17:18 ` Daniel P. Berrange
2017-01-04 21:26 ` Paolo Bonzini
2017-01-05 10:26 ` Daniel P. Berrange
2017-01-05 10:46 ` Paolo Bonzini [this message]
2016-12-23 18:26 ` [Qemu-devel] [PATCH 3/3] nbd: do not block on partial reply header reads Paolo Bonzini
2017-01-04 17:36 ` Eric Blake
2017-01-16 13:17 ` 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=edf6cdd7-8839-21a9-837b-cc07cbb2e7aa@redhat.com \
--to=pbonzini@redhat.com \
--cc=berrange@redhat.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).