All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: kvm@vger.kernel.org, mst@redhat.com, mtosatti@redhat.com,
	Xiao Guangrong <xiaoguangrong@tencent.com>,
	qemu-devel@nongnu.org, quintela@redhat.com, wei.w.wang@intel.com,
	guangrong.xiao@gmail.com, jiang.biao2@zte.com.cn,
	pbonzini@redhat.com
Subject: Re: [PATCH] migration: fix saving normal page even if it's been compressed
Date: Thu, 3 May 2018 10:21:36 +0800	[thread overview]
Message-ID: <20180503022136.GD8239@xz-mi> (raw)
In-Reply-To: <20180502153039.GF2679@work-vm>

On Wed, May 02, 2018 at 04:30:39PM +0100, Dr. David Alan Gilbert wrote:
> * Peter Xu (peterx@redhat.com) wrote:
> > On Sat, Apr 28, 2018 at 04:10:45PM +0800, guangrong.xiao@gmail.com wrote:
> > > From: Xiao Guangrong <xiaoguangrong@tencent.com>
> > > 
> > > Fix the bug introduced by da3f56cb2e767016 (migration: remove
> > > ram_save_compressed_page()), It should be 'return' rather than
> > > 'res'
> > > 
> > > Sorry for this stupid mistake :(
> > > 
> > > Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
> > 
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> > 
> > So is that only a performance degradation without this fix (since
> > AFAIU the compressing pages will be sent twice)?  Thanks,
> 
> It might be a bit more messy than that; because I think the
> 'compress_page_with_multi_thread' hands it to a compression thread to
> compress and write, but I don't think it waits for it.
> So I think you'll end up with this being written at the same time as the
> uncompressed data is written - I'm not sure what the other end receives.
> (Which makes me realise I don't think I understand how the compression
> threads are safe with their writing data out).

IIUC the compression threads are not really writting stuff to sockets,
but only to local RAM.  Please refer to do_data_compress() - when we
do do_compress_ram_page() we are writting to CompressParam.file which
is only a local buffer.  We flush this buffer in
flush_compressed_data() with qemu_put_qemu_file().  So IMHO the pages
are still serialized no matter whether it's a compressed page or
normal page.

Then IMHO it'll be fine, since no matter whether we receive the
compressed page or normal page first, we just update that page twice.
Then we have two possibilities:

- If the page is further modified, then both updates won't have any
  effect since we'll send a new version soon;

- If the page is not modified any more, then both the compressed page
  and normal page will have exactly the same content, then it won't
  matter much on which one we handled first on destination (note that
  we will still handle the pages sequentially on destination).

> 
> Anyway, I think we should get this one in quickly.

Yes.

Regards,

-- 
Peter Xu

WARNING: multiple messages have this Message-ID
From: Peter Xu <peterx@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: quintela@redhat.com, guangrong.xiao@gmail.com,
	pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	jiang.biao2@zte.com.cn, wei.w.wang@intel.com,
	Xiao Guangrong <xiaoguangrong@tencent.com>
Subject: Re: [Qemu-devel] [PATCH] migration: fix saving normal page even if it's been compressed
Date: Thu, 3 May 2018 10:21:36 +0800	[thread overview]
Message-ID: <20180503022136.GD8239@xz-mi> (raw)
In-Reply-To: <20180502153039.GF2679@work-vm>

On Wed, May 02, 2018 at 04:30:39PM +0100, Dr. David Alan Gilbert wrote:
> * Peter Xu (peterx@redhat.com) wrote:
> > On Sat, Apr 28, 2018 at 04:10:45PM +0800, guangrong.xiao@gmail.com wrote:
> > > From: Xiao Guangrong <xiaoguangrong@tencent.com>
> > > 
> > > Fix the bug introduced by da3f56cb2e767016 (migration: remove
> > > ram_save_compressed_page()), It should be 'return' rather than
> > > 'res'
> > > 
> > > Sorry for this stupid mistake :(
> > > 
> > > Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
> > 
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> > 
> > So is that only a performance degradation without this fix (since
> > AFAIU the compressing pages will be sent twice)?  Thanks,
> 
> It might be a bit more messy than that; because I think the
> 'compress_page_with_multi_thread' hands it to a compression thread to
> compress and write, but I don't think it waits for it.
> So I think you'll end up with this being written at the same time as the
> uncompressed data is written - I'm not sure what the other end receives.
> (Which makes me realise I don't think I understand how the compression
> threads are safe with their writing data out).

IIUC the compression threads are not really writting stuff to sockets,
but only to local RAM.  Please refer to do_data_compress() - when we
do do_compress_ram_page() we are writting to CompressParam.file which
is only a local buffer.  We flush this buffer in
flush_compressed_data() with qemu_put_qemu_file().  So IMHO the pages
are still serialized no matter whether it's a compressed page or
normal page.

Then IMHO it'll be fine, since no matter whether we receive the
compressed page or normal page first, we just update that page twice.
Then we have two possibilities:

- If the page is further modified, then both updates won't have any
  effect since we'll send a new version soon;

- If the page is not modified any more, then both the compressed page
  and normal page will have exactly the same content, then it won't
  matter much on which one we handled first on destination (note that
  we will still handle the pages sequentially on destination).

> 
> Anyway, I think we should get this one in quickly.

Yes.

Regards,

-- 
Peter Xu

  reply	other threads:[~2018-05-03  2:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-28  8:10 [PATCH] migration: fix saving normal page even if it's been compressed guangrong.xiao
2018-04-28  8:10 ` [Qemu-devel] " guangrong.xiao
2018-05-02  2:46 ` Peter Xu
2018-05-02  2:46   ` [Qemu-devel] " Peter Xu
2018-05-02 15:30   ` Dr. David Alan Gilbert
2018-05-02 15:30     ` [Qemu-devel] " Dr. David Alan Gilbert
2018-05-03  2:21     ` Peter Xu [this message]
2018-05-03  2:21       ` Peter Xu
2018-05-03  3:13   ` Xiao Guangrong
2018-05-03  3:13     ` [Qemu-devel] " Xiao Guangrong

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=20180503022136.GD8239@xz-mi \
    --to=peterx@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=guangrong.xiao@gmail.com \
    --cc=jiang.biao2@zte.com.cn \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=wei.w.wang@intel.com \
    --cc=xiaoguangrong@tencent.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.