From: Paolo Bonzini <pbonzini@redhat.com>
To: Umesh Deshpande <udeshpan@redhat.com>
Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org,
quintela@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH v4 4/5] separate thread for VM migration
Date: Wed, 17 Aug 2011 00:13:27 -0700 [thread overview]
Message-ID: <4E4B6A17.60302@redhat.com> (raw)
In-Reply-To: <d11a5c990004ea81b59fb4984e18358223e674b8.1313552764.git.udeshpan@redhat.com>
On 08/16/2011 08:56 PM, Umesh Deshpande wrote:
> + qemu_mutex_lock_ramlist();
Taken locks: iothread, ramlist
> + qemu_mutex_unlock_iothread();
Taken locks: ramlist
> + s->wait_for_unfreeze(s);
> + qemu_mutex_lock_iothread();
Taken locks: ramlist, iothread
You'd have a deadlock here if hypothetically you had two migrations at
the same time.
> + qemu_mutex_unlock_ramlist();
But in general, why this locking? The buffered file need not know
anything about the ram list and its mutex. Only ram_save_live needs to
hold the ramlist lock---starting just before sort_ram_list and ending
just after the end of stage 3. That should be part of patch 2.
Actually buffered_file.c should ideally not even take the iothread lock!
The code there is only copying data from a private buffer to a file
descriptor; neither is shared. It's migrate_fd_put_buffer that should
take care of locking. This is an example of why keeping the separation
of QEMUBufferedFile is a good idea at least for now.
I am still kind of unconvinced about calling qemu_fclose from the
migration thread. You still have one instance of cancellation in the
iothread when migrate_fd_release is called. Ideally, as soon as
migration finishes or has an error you could trigger a bottom half that
closes the file (which in turn joins the thread). Migration state
notifiers should also be run only from the iothread. Failure to do so
(or in general lack of a policy of what runs where) can lead to very
difficult bugs. Not so much hard to debug in this case (we have a
global lock, so things cannot go _that_ bad), but hard to fix without
redoing everything.
However, this patch is a good start (with locking fixed). It should
takes several incremental steps before getting there, including
incredible simplification if you take into account that migration can
block and wait_for_unfreeze can disappear. In the end it probably
should be committed as a single patch, but I'm liking the patches more
and more.
Paolo
next prev parent reply other threads:[~2011-08-17 7:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 3:56 [Qemu-devel] [RFC PATCH v4 0/5] Separate thread for VM migration Umesh Deshpande
2011-08-17 3:56 ` [Qemu-devel] [RFC PATCH v4 1/5] MRU ram list Umesh Deshpande
2011-08-17 3:56 ` [Qemu-devel] [RFC PATCH v4 2/5] ramlist mutex Umesh Deshpande
2011-08-17 6:28 ` Paolo Bonzini
2011-08-19 6:20 ` Umesh Deshpande
2011-08-22 6:48 ` Paolo Bonzini
2011-08-23 9:15 ` Marcelo Tosatti
2011-08-23 9:17 ` Marcelo Tosatti
2011-08-23 11:41 ` Paolo Bonzini
2011-08-23 12:16 ` Marcelo Tosatti
2011-08-17 3:56 ` [Qemu-devel] [RFC PATCH v4 3/5] separate migration bitmap Umesh Deshpande
2011-08-17 3:56 ` [Qemu-devel] [RFC PATCH v4 4/5] separate thread for VM migration Umesh Deshpande
2011-08-17 7:13 ` Paolo Bonzini [this message]
2011-08-17 3:56 ` [Qemu-devel] [RFC PATCH v3 5/5] Making iothread block for migrate_cancel Umesh Deshpande
2011-08-17 7:14 ` Paolo Bonzini
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=4E4B6A17.60302@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=udeshpan@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).