qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Pavel Butsykin <pbutsykin@virtuozzo.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Fam Zheng <famz@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 3/4] migration: avoid recursive AioContext locking in save_vmstate()
Date: Wed, 14 Jun 2017 16:43:24 +0200	[thread overview]
Message-ID: <20170614144324.GA4785@noname.redhat.com> (raw)
In-Reply-To: <99f414f1-7a0f-b659-be81-d6f38fd04ff4@virtuozzo.com>

Am 14.06.2017 um 15:15 hat Pavel Butsykin geschrieben:
> On 14.06.2017 13:10, Pavel Butsykin wrote:
> >
> >On 22.05.2017 16:57, Stefan Hajnoczi wrote:
> >>AioContext was designed to allow nested acquire/release calls.  It uses
> >>a recursive mutex so callers don't need to worry about nesting...or so
> >>we thought.
> >>
> >>BDRV_POLL_WHILE() is used to wait for block I/O requests.  It releases
> >>the AioContext temporarily around aio_poll().  This gives IOThreads a
> >>chance to acquire the AioContext to process I/O completions.
> >>
> >>It turns out that recursive locking and BDRV_POLL_WHILE() don't mix.
> >>BDRV_POLL_WHILE() only releases the AioContext once, so the IOThread
> >>will not be able to acquire the AioContext if it was acquired
> >>multiple times.
> >>
> >>Instead of trying to release AioContext n times in BDRV_POLL_WHILE(),
> >>this patch simply avoids nested locking in save_vmstate().  It's the
> >>simplest fix and we should step back to consider the big picture with
> >>all the recent changes to block layer threading.
> >>
> >>This patch is the final fix to solve 'savevm' hanging with -object
> >>iothread.
> >
> >The same I see in external_snapshot_prepare():
> >[...]
> >and at the moment BDRV_POLL_WHILE(bs, flush_co.ret == NOT_DONE),
> >we have at least two locks.. So here is another deadlock.
> 
> Sorry, here different kind of deadlock. In external_snapshot case, the
> deadlock can happen only if state->old_bs->aio_context == my_iothread->ctx,
> because in this case the aio_co_enter() always calls aio_co_schedule():

Can you please write qemu-iotests case for any deadlock case that we're
seeing? Stefan, we could also use one for the bug fixed in this series.

Kevin

  reply	other threads:[~2017-06-14 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 13:57 [Qemu-devel] [PATCH v3 0/4] block: fix 'savevm' hang with -object iothread Stefan Hajnoczi
2017-05-22 13:57 ` [Qemu-devel] [PATCH v3 1/4] block: count bdrv_co_rw_vmstate() requests Stefan Hajnoczi
2017-05-22 13:57 ` [Qemu-devel] [PATCH v3 2/4] block: use BDRV_POLL_WHILE() in bdrv_rw_vmstate() Stefan Hajnoczi
2017-05-22 13:57 ` [Qemu-devel] [PATCH v3 3/4] migration: avoid recursive AioContext locking in save_vmstate() Stefan Hajnoczi
2017-06-14 10:10   ` Pavel Butsykin
2017-06-14 13:15     ` Pavel Butsykin
2017-06-14 14:43       ` Kevin Wolf [this message]
2017-06-15 13:33         ` Pavel Butsykin
2017-05-22 13:57 ` [Qemu-devel] [PATCH v3 4/4] migration: use bdrv_drain_all_begin/end() instead bdrv_drain_all() Stefan Hajnoczi
2017-05-22 17:40   ` Eric Blake
2017-05-30 13:52 ` [Qemu-devel] [Qemu-block] [PATCH v3 0/4] block: fix 'savevm' hang with -object iothread Stefan Hajnoczi
2017-06-12 13:47 ` Stefan Hajnoczi
2017-06-13 12:14   ` Kevin Wolf

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=20170614144324.GA4785@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pbutsykin@virtuozzo.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).