public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Umesh Deshpande <udeshpan@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] Separate migration thread
Date: Tue, 30 Aug 2011 09:31:50 -0300	[thread overview]
Message-ID: <20110830123149.GB19450@amt.cnet> (raw)
In-Reply-To: <4E5CA3CB.5070707@redhat.com>

On Tue, Aug 30, 2011 at 10:48:11AM +0200, Paolo Bonzini wrote:
> On 08/29/2011 08:49 PM, Marcelo Tosatti wrote:
> >>>  -static void buffered_rate_tick(void *opaque)
> >>>  +static void *migrate_vm(void *opaque)
> >>>    {
> >
> >buffered_file.c was generic code that has now become migration specific
> >(although migration was the only user). So it should either stop
> >pretending to be generic code, by rename to migration_thread.c along
> >with un-exporting interfaces, or it should remain generic and therefore
> >all migration specific knowledge moved somewhere else.
> 
> Actually, the thread function is ill-named.  buffered_file.c is
> still generic code (or if it is not, it's a bug), except it should
> be called threaded_file.c.
> 
> Moving it to migration.c is also an option of course.  I asked Umesh
> to keep the abstraction for now, because it helped pinpointing
> places where abstractions were leaking in (such as the
> qemu_mutex_unlock_migrate_ram call that you found).

Fair enough, its indeed generic except misuse of ram lock.

> >>+    int64_t current_time, expire_time = qemu_get_clock_ms(rt_clock) + 100;
> >>+    struct timeval tv = { .tv_sec = 0, .tv_usec = 100000};
> >
> >qemu_get_clock_ms should happen under iothread lock.
> 
> For rt_clock it is safe.  Should be documented, though.
>
> >>+    qemu_mutex_lock_migrate_ram();
> >>     s = migrate_to_fms(current_migration);
> >>     if (s && s->file) {
> >>         qemu_file_set_rate_limit(s->file, max_throttle);
> >>     }
> >>+    qemu_mutex_unlock_migrate_ram();
> >
> >This lock protects the RAMlist, and only the RAMlist, but here its
> >being used to protect migration thread data. As noted above, a new lock
> >should be introduced.
> 
> Even better, freeing the buffered_file should be only done in the
> iothread (if this is not the case) so that the lock can be pushed
> down to buffered_set_rate_limit...

Sounds good.

> >+        qemu_mutex_lock_migrate_ram();
> >         if (qemu_fclose(s->file) != 0) {
> >             ret = -1;
> >         }
> >+        qemu_mutex_unlock_migrate_ram();
> 
> ... and buffered_close (if a lock turns out to be needed at all).
>
> Paolo

  reply	other threads:[~2011-08-30 12:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-27 18:09 [PATCH 0/5] Separate thread for VM migration Umesh Deshpande
2011-08-27 18:09 ` [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 ` [PATCH 2/5] MRU ram block list Umesh Deshpande
2011-08-27 18:09 ` [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
2011-08-27 18:09 ` [PATCH 4/5] Separate migration dirty bitmap Umesh Deshpande
2011-08-27 18:09 ` [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 [this message]
2011-08-29 10:20 ` [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=20110830123149.GB19450@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --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