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: Wed, 4 Jan 2017 16:26:24 -0500 (EST) [thread overview]
Message-ID: <828473785.4444002.1483565184407.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170104171823.GJ10541@redhat.com>
> > @@ -84,8 +83,8 @@ struct QIOChannel {
> > unsigned int features; /* bitmask of QIOChannelFeatures */
> > char *name;
> > AioContext *ctx;
> > - QIOChannelRestart *read_coroutine;
> > - QIOChannelRestart *write_coroutine;
> > + Coroutine *read_coroutine;
> > + Coroutine *write_coroutine;
>
> Seems this ought to have been squashed into the previous patch
Yeah, sent this last thing before Christmas and it shows. :)
> > +static void qio_channel_set_fd_handlers(QIOChannel *ioc)
> > +{
> > + IOHandler *rd_handler = NULL, *wr_handler = NULL;
> > +
> > + if (ioc->read_coroutine) {
> > + rd_handler = qio_channel_restart_read;
> > + }
> > + if (ioc->write_coroutine) {
> > + rd_handler = qio_channel_restart_write;
> > + }
> > +
> > + qio_channel_set_fd_handler(ioc,
> > + ioc->ctx ? ioc->ctx :
> > iohandler_get_aio_context(),
> > + rd_handler, wr_handler, ioc);
> > +}
>
> ioc->read_coroutine & ioc->write_coroutine can only be non-NULL during
> a qio_channel_yield() caller. So it seems that calling
> qio_channel_set_fd_handlers() from the qio_channel_set_aio_context()
> method in the previous patch is not required, as those two callback
> pointers will always be NULL.
Not necessarily. You can have one coroutine calling qio_channel_yield(),
and then the non-coroutine code can call qio_channel_set_aio_context()
before the coroutine reenters.
This actually happens in the next patch. Where the NBD socket is quiescent
and no response is in flight, such as during a bdrv_drain_begin/end()
section, the "coroutine that receives NBD headers" has yielded. This
is also the time when set_aio_context can be called.
> > + 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.
> If it does need to be exclusive though, can you update the API
> docs for this method to mention that.
Sure.
Thanks for the speedy review!
Paolo
next prev parent reply other threads:[~2017-01-04 21:26 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 [this message]
2017-01-05 10:26 ` Daniel P. Berrange
2017-01-05 10:46 ` Paolo Bonzini
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=828473785.4444002.1483565184407.JavaMail.zimbra@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 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.