[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v8 42/54] Postcopy: Use helpers to map pages dur
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v8 42/54] Postcopy: Use helpers to map pages during migration |
Date: |
Fri, 30 Oct 2015 16:35:49 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
* Juan Quintela (address@hidden) wrote:
> "Dr. David Alan Gilbert (git)" <address@hidden> wrote:
> > From: "Dr. David Alan Gilbert" <address@hidden>
> >
> > In postcopy, the destination guest is running at the same time
> > as it's receiving pages; as we receive new pages we must put
> > them into the guests address space atomically to avoid a running
> > CPU accessing a partially written page.
> >
> > Use the helpers in postcopy-ram.c to map these pages.
> >
> > qemu_get_buffer_in_place is used to avoid a copy out of qemu_file
> > in the case that postcopy is going to do a copy anyway.
> >
> > Signed-off-by: Dr. David Alan Gilbert <address@hidden>
> > ---
> > migration/ram.c | 128
> > +++++++++++++++++++++++++++++++++++++++++++++-----------
> > 1 file changed, 103 insertions(+), 25 deletions(-)
> >
> > diff --git a/migration/ram.c b/migration/ram.c
> > + postcopy_place_needed = false;
> > + if (flags & (RAM_SAVE_FLAG_COMPRESS | RAM_SAVE_FLAG_PAGE |
> > + RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE)) {
> > + host = host_from_stream_offset(f, mis, addr, flags);
> > + if (!host) {
> > + error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
> > + ret = -EINVAL;
> > + break;
> > + }
> > + page_buffer = host;
>
> You can move this bit of code here in a different patch, makes review easier.
> all_zero can also be on that patch.
Done; this is now 'ram_load: Factor out host_from_stream_offset call and check'
>
> You are reusingh ram_load, but have lots and lots of
>
> if (postcopy_running) {
>
> } else {
>
> }
>
> I think that it would be easier to just have:
>
> if (postcopy_running) {
> ram_load_postcopy()
> } else {
> ram_load_precopy{}
> }
>
> You duplicate a bit of code, but remove lots of ifs from the equation,
> not sure which one is really easier. I just hate bits like the
> following one.
>
> > @@ -2062,32 +2123,36 @@ static int ram_load(QEMUFile *f, void *opaque, int
> > version_id)
> > }
> > break;
> > case RAM_SAVE_FLAG_COMPRESS:
> > ch = qemu_get_byte(f);
> > - ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
> > + if (!postcopy_running) {
> > + ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
> > + } else {
> > + memset(page_buffer, ch, TARGET_PAGE_SIZE);
> > + if (ch) {
> > + all_zero = false;
> > + }
> > + }
>
Yeh, I've split that out now into ram_load_postcopy (called from just
before the main loop in ram_load); as you say it is a bit bigger,
but clearer.
> > + if (postcopy_running) {
>
>
> As discussed on irc, I still think that having a RAM_SAVE_HOST_PAGE make
> everything much, much clearer and easier, but I agree that is not
> trivial with current code.
(I've moved this comment down a bit in this reply).
Actually, now that the postcopy load code is in a separate routine, it might
be possible to reorder things a bit since we know all of these pages are
host-page-sized.
Dave
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v8 38/54] Page request: Add MIG_RP_MSG_REQ_PAGES reverse command, (continued)
- [Qemu-devel] [PATCH v8 39/54] Page request: Process incoming page request, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 40/54] Page request: Consume pages off the post-copy queue, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 42/54] Postcopy: Use helpers to map pages during migration, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 43/54] Don't sync dirty bitmaps in postcopy, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 41/54] postcopy_ram.c: place_page and helpers, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 44/54] Don't iterate on precopy-only devices during postcopy, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 45/54] Host page!=target page: Cleanup bitmaps, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 46/54] postcopy: Check order of received target pages, Dr. David Alan Gilbert (git), 2015/10/01