From: Stefan Hajnoczi <stefanha@gmail.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu block <qemu-block@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>, Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3] util/async: make bh_aio_poll() O(1)
Date: Fri, 21 Feb 2020 09:53:31 +0000 [thread overview]
Message-ID: <CAJSP0QU4Nvw5q3U2BMkQKeSB=Rpt9o3t29-hnzULi6yP9A1pQA@mail.gmail.com> (raw)
In-Reply-To: <20200221093951.1414693-1-stefanha@redhat.com>
On Fri, Feb 21, 2020 at 9:40 AM Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> The ctx->first_bh list contains all created BHs, including those that
> are not scheduled. The list is iterated by the event loop and therefore
> has O(n) time complexity with respected to the number of created BHs.
>
> Rewrite BHs so that only scheduled or deleted BHs are enqueued.
> Only BHs that actually require action will be iterated.
>
> One semantic change is required: qemu_bh_delete() enqueues the BH and
> therefore invokes aio_notify(). The
> tests/test-aio.c:test_source_bh_delete_from_cb() test case assumed that
> g_main_context_iteration(NULL, false) returns false after
> qemu_bh_delete() but it now returns true for one iteration. Fix up the
> test case.
>
> This patch makes aio_compute_timeout() and aio_bh_poll() drop from a CPU
> profile reported by perf-top(1). Previously they combined to 9% CPU
> utilization when AioContext polling is commented out and the guest has 2
> virtio-blk,num-queues=1 and 99 virtio-blk,num-queues=32 devices.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> v3:
> * Use QSLIST_FOREACH_RCU() and QSLIST_FIRST_RCU() [Paolo]
I forgot to include Paolo's R-b that he gave conditional on making this change:
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2020-02-21 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 9:39 [PATCH v3] util/async: make bh_aio_poll() O(1) Stefan Hajnoczi
2020-02-21 9:53 ` Stefan Hajnoczi [this message]
2020-02-21 13:55 ` 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='CAJSP0QU4Nvw5q3U2BMkQKeSB=Rpt9o3t29-hnzULi6yP9A1pQA@mail.gmail.com' \
--to=stefanha@gmail.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 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).