All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Li, Liang Z" <liang.z.li@intel.com>
To: "quintela@redhat.com" <quintela@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"lcapitulino@redhat.com" <lcapitulino@redhat.com>,
	"Zhang, Yang Z" <yang.z.zhang@intel.com>,
	"amit.shah@redhat.com" <amit.shah@redhat.com>,
	"dgilbert@redhat.com" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [v6 08/14] migration: Add the core code of multi-thread compression
Date: Sat, 28 Mar 2015 06:11:16 +0000	[thread overview]
Message-ID: <F2CBF3009FA73547804AE4C663CAB28E4E2580@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <87oanevhs2.fsf@neno.neno>

> -
> >  1 file changed, 177 insertions(+), 7 deletions(-)
> >
> > diff --git a/arch_init.c b/arch_init.c index 48cae22..9f63c0f 100644
> > --- a/arch_init.c
> > +++ b/arch_init.c
> > @@ -355,12 +355,33 @@ static DecompressParam *decomp_param;  static
> > QemuThread *decompress_threads;  static uint8_t
> *compressed_data_buf;
> >
> > +static int do_compress_ram_page(CompressParam *param);
> > +
> >  static void *do_data_compress(void *opaque)  {
> > -    while (!quit_comp_thread) {
> > +    CompressParam *param = opaque;
> >
> > -    /* To be done */
> Change this line to
> 
> > +    while (!quit_comp_thread) {
> 
>   while(true) {
> 
> > +        qemu_mutex_lock(&param->mutex);
> > +        /* Re-check the quit_comp_thread in case of
> > +         * terminate_compression_threads is called just before
> > +         * qemu_mutex_lock(&param->mutex) and after
> > +         * while(!quit_comp_thread), re-check it here can make
> > +         * sure the compression thread terminate as expected.
> > +         */
> Change this
> 
> > +        while (!param->start && !quit_comp_thread) {
> 
> to
> 
> while (!param->start && !parm->quit) {
> 
> > +            qemu_cond_wait(&param->cond, &param->mutex);
> > +        }
> 
> And this
> 
> > +        if (!quit_comp_thread) {
> 
> to
> 
>       if (!param->quit) {
> > +            do_compress_ram_page(param);
> > +        }
> 
> Take care here of exiting correctly of the loop.
> Notice that the only case where we are not going to take the look is the last
> iteration, so I think the optimization don't gives us nothing (in this place), no?
> 
> > +        param->start = false;
> > +        qemu_mutex_unlock(&param->mutex);
> >
> > +        qemu_mutex_lock(comp_done_lock);
> > +        param->done = true;
> > +        qemu_cond_signal(comp_done_cond);
> > +        qemu_mutex_unlock(comp_done_lock);
> >      }
> 
> 
> >
> >      return NULL;
> > @@ -368,9 +389,15 @@ static void *do_data_compress(void *opaque)
> >
> >  static inline void terminate_compression_threads(void)
> >  {
> > -    quit_comp_thread = true;
> > +    int idx, thread_count;
> >
> > -    /* To be done */
> > +    thread_count = migrate_compress_threads();
> > +    quit_comp_thread = true;
> 
> 
> > +    for (idx = 0; idx < thread_count; idx++) {
> > +        qemu_mutex_lock(&comp_param[idx].mutex);
> Add this
>            comp_param[idx].quit = true;
> 
> 
> And for now on, quit_comp_thread is only used on migration_thread, so it
> should be safe to use, no?
> 
> flush_compresed_data() is only ever called from the migration_thread, so no
> lock there needed either.

Now that the lock is no needed in flush_comrepssed_data(), it looks good to me.
I will change the code according to your suggestion. 

And could you ask the related maintainers to review the other parts of my patches,
especially the 3 patches related to the qmp and hmp interfaces. 

Thanks Juan!

Liang

  reply	other threads:[~2015-03-28  6:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23  8:32 [Qemu-devel] [PATCH v6 0/14] migration: Add a new feature to do live migration Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 01/14] docs: Add a doc about multiple thread compression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 02/14] migration: Add the framework of multi-thread compression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 03/14] migration: Add the framework of multi-thread decompression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 04/14] qemu-file: Add compression functions to QEMUFile Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 05/14] arch_init: Alloc and free data struct for compression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 06/14] arch_init: Add and free data struct for decompression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 07/14] migration: Split save_zero_page from ram_save_page Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 08/14] migration: Add the core code of multi-thread compression Liang Li
2015-03-25 11:47   ` Juan Quintela
2015-03-26  2:37     ` Li, Liang Z
2015-03-26 10:27       ` Juan Quintela
2015-03-27  2:59         ` Li, Liang Z
2015-03-27 10:47   ` Juan Quintela
2015-03-28  6:11     ` Li, Liang Z [this message]
2015-03-23  8:32 ` [Qemu-devel] [v6 09/14] migration: Make compression co-work with xbzrle Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 10/14] migration: Add the core code for decompression Liang Li
2015-03-25 11:56   ` Juan Quintela
2015-03-26  2:46     ` Li, Liang Z
2015-03-23  8:32 ` [Qemu-devel] [v6 11/14] migration: Add interface to control compression Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 12/14] migration: Use an array instead of 3 parameters Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 13/14] migration: Add qmp commands to set and query parameters Liang Li
2015-03-23  8:32 ` [Qemu-devel] [v6 14/14] migration: Add hmp interface " Liang Li
2015-04-02  1:16 ` [Qemu-devel] [PATCH v6 0/14] migration: Add a new feature to do live migration Li, Liang Z

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=F2CBF3009FA73547804AE4C663CAB28E4E2580@shsmsx102.ccr.corp.intel.com \
    --to=liang.z.li@intel.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yang.z.zhang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.