qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Umesh Deshpande <udeshpan@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 3/5] Migration thread mutex
Date: Mon, 29 Aug 2011 15:40:49 -0300	[thread overview]
Message-ID: <20110829184049.GA3783@amt.cnet> (raw)
In-Reply-To: <be8967cc1ebb713c8557ce72c6d6e989b7c77042.1314398066.git.udeshpan@redhat.com>

On Sat, Aug 27, 2011 at 02:09:46PM -0400, Umesh Deshpande wrote:
> This patch implements migrate_ram mutex, which protects the RAMBlock list
> traversal in the migration thread during the transfer of a ram from their
> addition/removal from the iothread.
> 
> Note: Combination of iothread mutex and migration thread mutex works as a
> rw-lock. Both mutexes are acquired while modifying the ram_list members or RAM
> block list.
> 
> Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
> ---
>  arch_init.c   |   21 +++++++++++++++++++++
>  cpu-all.h     |    3 +++
>  exec.c        |   23 +++++++++++++++++++++++
>  qemu-common.h |    2 ++
>  4 files changed, 49 insertions(+), 0 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 484b39d..9d02270 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -109,6 +109,7 @@ static int is_dup_page(uint8_t *page, uint8_t ch)
>  
>  static RAMBlock *last_block;
>  static ram_addr_t last_offset;
> +static uint64_t last_version;
>  
>  static int ram_save_block(QEMUFile *f)
>  {
> @@ -170,6 +171,7 @@ static int ram_save_block(QEMUFile *f)
>  
>      last_block = block;
>      last_offset = offset;
> +    last_version = ram_list.version;
>  
>      return bytes_sent;
>  }
> @@ -270,6 +272,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>          bytes_transferred = 0;
>          last_block = NULL;
>          last_offset = 0;
> +        last_version = ram_list.version = 0;
>          sort_ram_list();
>  
>          /* Make sure all dirty bits are set */
> @@ -298,6 +301,17 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
>      bytes_transferred_last = bytes_transferred;
>      bwidth = qemu_get_clock_ns(rt_clock);
>  
> +    if (stage != 3) {
> +        qemu_mutex_lock_migrate_ram();
> +        qemu_mutex_unlock_iothread();
> +    }

Dropping the iothread lock from within a timer handler is not safe.
This change to ram_save_live should be moved to the patch where 
migration thread is introduced.

  parent reply	other threads:[~2011-08-29 18:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-27 18:09 [Qemu-devel] [PATCH 0/5] Separate thread for VM migration Umesh Deshpande
2011-08-27 18:09 ` [Qemu-devel] [PATCH 1/5] Support for vm_stop from the migration thread Umesh Deshpande
2011-08-29 16:56   ` Marcelo Tosatti
2011-08-30  8:40     ` Paolo Bonzini
2011-08-27 18:09 ` [Qemu-devel] [PATCH 2/5] MRU ram block list Umesh Deshpande
2011-08-27 18:09 ` [Qemu-devel] [PATCH 3/5] Migration thread mutex Umesh Deshpande
2011-08-29  9:04   ` Stefan Hajnoczi
2011-08-29 13:49     ` Umesh Deshpande
2011-08-29 18:40   ` Marcelo Tosatti [this message]
2011-08-27 18:09 ` [Qemu-devel] [PATCH 4/5] Separate migration dirty bitmap Umesh Deshpande
2011-08-27 18:09 ` [Qemu-devel] [PATCH 5/5] Separate migration thread Umesh Deshpande
2011-08-29  9:09   ` Stefan Hajnoczi
2011-08-29 13:49     ` Umesh Deshpande
2011-08-29 18:49   ` Marcelo Tosatti
2011-08-30  8:48     ` Paolo Bonzini
2011-08-30 12:31       ` Marcelo Tosatti
2011-08-29 10:20 ` [Qemu-devel] [PATCH 0/5] Separate thread for VM migration Paolo Bonzini
2011-08-31  3:53   ` Umesh Deshpande

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=20110829184049.GA3783@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --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).