From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <fam@euphon.net>, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v2 3/3] aio-posix: keep aio_notify_me disabled during polling
Date: Thu, 6 Aug 2020 11:52:41 +0100 [thread overview]
Message-ID: <20200806105241.GA379937@stefanha-x1.localdomain> (raw)
In-Reply-To: <8e066cf0-e5f9-283c-eedd-47974bf4bbac@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]
On Wed, Aug 05, 2020 at 06:37:45PM +0200, Paolo Bonzini wrote:
> On 05/08/20 12:00, Stefan Hajnoczi wrote:
> > +
> > + /*
> > + * aio_notify can avoid the expensive event_notifier_set if
> > + * everything (file descriptors, bottom halves, timers) will
> > + * be re-evaluated before the next blocking poll(). This is
> > + * already true when aio_poll is called with blocking == false;
> > + * if blocking == true, it is only true after poll() returns,
> > + * so disable the optimization now.
> > + */
> > + if (use_notify_me) {
> > + atomic_set(&ctx->notify_me, atomic_read(&ctx->notify_me) + 2);
> > + /*
> > + * Write ctx->notify_me before reading ctx->notified. Pairs with
> > + * smp_mb in aio_notify().
> > + */
> > + smp_mb();
> > +
> > + /* Don't block if aio_notify() was called */
> > + if (atomic_read(&ctx->notified)) {
> > + timeout = 0;
> > + }
>
> Aha, this is the trick: "timeout = 0" also applies if a timer was moved
> early. In this case you uselessly keep notify_me set for a bit, but
> it's okay. Nice!
>
> The code can be simplified a bit more, since the use_notify_me variable
> is just "timeout":
Good point. I'll send another revision.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-08-06 12:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 10:00 [PATCH v2 0/3] aio-posix: keep aio_notify_me disabled during polling Stefan Hajnoczi
2020-08-05 10:00 ` [PATCH v2 1/3] async: rename event_notifier_dummy_cb/poll() Stefan Hajnoczi
2020-08-06 7:10 ` Philippe Mathieu-Daudé
2020-08-05 10:00 ` [PATCH v2 2/3] async: always set ctx->notified in aio_notify() Stefan Hajnoczi
2020-08-05 16:26 ` Paolo Bonzini
2020-08-05 10:00 ` [PATCH v2 3/3] aio-posix: keep aio_notify_me disabled during polling Stefan Hajnoczi
2020-08-05 16:37 ` Paolo Bonzini
2020-08-06 10:52 ` Stefan Hajnoczi [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=20200806105241.GA379937@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=fam@euphon.net \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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).