From: Jeff Cody <jcody@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, famz@redhat.com, stefanha@redhat.com,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH for-2.9] blockjob: avoid recursive AioContext locking
Date: Wed, 22 Mar 2017 08:05:38 -0400 [thread overview]
Message-ID: <20170322120538.GE3411@localhost.localdomain> (raw)
In-Reply-To: <1490118490-5597-1-git-send-email-pbonzini@redhat.com>
On Tue, Mar 21, 2017 at 06:48:10PM +0100, Paolo Bonzini wrote:
> Streaming or any other block job hangs when performed on a block device
> that has a non-default iothread. This happens because the AioContext
> is acquired twice by block_job_defer_to_main_loop_bh and then released
> only once by BDRV_POLL_WHILE. (Insert rants on recursive mutexes, which
>
> unfortunately are a temporary but necessary evil for iothreads at the
> moment).
>
> Luckily, the reason for the double acquisition is simple; the function
> acquires the AioContext for both the job iothread and the BDS iothread,
> in case the BDS iothread was changed while the job was running. It
> is therefore enough to skip the second acquisition when the two
> AioContexts are one and the same.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> blockjob.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/blockjob.c b/blockjob.c
> index 69126af..2159df7 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -755,12 +755,16 @@ static void block_job_defer_to_main_loop_bh(void *opaque)
>
> /* Fetch BDS AioContext again, in case it has changed */
> aio_context = blk_get_aio_context(data->job->blk);
> - aio_context_acquire(aio_context);
> + if (aio_context != data->aio_context) {
> + aio_context_acquire(aio_context);
> + }
>
> data->job->deferred_to_main_loop = false;
> data->fn(data->job, data->opaque);
>
> - aio_context_release(aio_context);
> + if (aio_context != data->aio_context) {
> + aio_context_release(aio_context);
> + }
>
> aio_context_release(data->aio_context);
>
> --
> 1.8.3.1
>
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
next prev parent reply other threads:[~2017-03-22 12:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 17:48 [Qemu-devel] [PATCH for-2.9] blockjob: avoid recursive AioContext locking Paolo Bonzini
2017-03-21 19:15 ` Eric Blake
2017-03-22 12:05 ` Jeff Cody [this message]
2017-03-22 12:15 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-03-22 15:32 ` [Qemu-devel] " John Snow
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=20170322120538.GE3411@localhost.localdomain \
--to=jcody@redhat.com \
--cc=famz@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).