[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v7 34/42] Postcopy: Use helpers to map pages dur
From: |
Juan Quintela |
Subject: |
Re: [Qemu-devel] [PATCH v7 34/42] Postcopy: Use helpers to map pages during migration |
Date: |
Tue, 14 Jul 2015 14:34:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
"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_less_copy 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>
> @@ -1742,7 +1752,6 @@ static inline void *host_from_stream_offset(QEMUFile *f,
> error_report("Ack, bad migration stream!");
> return NULL;
> }
> -
Dont' belong here O:-)
> return memory_region_get_ram_ptr(block->mr) + offset;
> }
>
> @@ -1881,6 +1890,16 @@ static int ram_load(QEMUFile *f, void *opaque, int
> version_id)
> int flags = 0, ret = 0;
> static uint64_t seq_iter;
> int len = 0;
> + /*
> + * System is running in postcopy mode, page inserts to host memory must
> be
> + * atomic
> + */
> + MigrationIncomingState *mis = migration_incoming_get_current();
> + bool postcopy_running = postcopy_state_get(mis) >=
> + POSTCOPY_INCOMING_LISTENING;
> + void *postcopy_host_page = NULL;
> + bool postcopy_place_needed = false;
> + bool matching_page_sizes = qemu_host_page_size == TARGET_PAGE_SIZE;
>
> seq_iter++;
>
> @@ -1896,13 +1915,57 @@ static int ram_load(QEMUFile *f, void *opaque, int
> version_id)
> rcu_read_lock();
> while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
> ram_addr_t addr, total_ram_bytes;
> - void *host;
> + void *host = 0;
> + void *page_buffer = 0;
> + void *postcopy_place_source = 0;
NULL, NULL, NULL?
BTW, do we really need postcopy_place_source? I think that just doing
s/postcopy_place_source/postcopy_host_page/ would do?
> uint8_t ch;
> + bool all_zero = false;
>
> addr = qemu_get_be64(f);
> flags = addr & ~TARGET_PAGE_MASK;
> addr &= TARGET_PAGE_MASK;
>
> + if (flags & (RAM_SAVE_FLAG_COMPRESS | RAM_SAVE_FLAG_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;
> + }
> + if (!postcopy_running) {
> + page_buffer = host;
> + } else {
> + /*
> + * Postcopy requires that we place whole host pages
> atomically.
> + * To make it atomic, the data is read into a temporary page
> + * that's moved into place later.
> + * The migration protocol uses, possibly smaller,
> target-pages
> + * however the source ensures it always sends all the
> components
> + * of a host page in order.
> + */
> + if (!postcopy_host_page) {
> + postcopy_host_page = postcopy_get_tmp_page(mis);
> + }
> + page_buffer = postcopy_host_page +
> + ((uintptr_t)host & ~qemu_host_page_mask);
> + /* If all TP are zero then we can optimise the place */
> + if (!((uintptr_t)host & ~qemu_host_page_mask)) {
I don't understand the test, the comment or both :-(
How you arrive from that test that this is a page full of zeros is a
mistery to me :p
Head hurts, would try to convince myself that the rest of changes are ok.
- Re: [Qemu-devel] [PATCH v7 34/42] Postcopy: Use helpers to map pages during migration,
Juan Quintela <=