Skip to content

Commit

Permalink
postcopy: Record largest page size
Browse files Browse the repository at this point in the history
Record the largest page size in use; we'll need it soon for allocating
temporary buffers.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20170224182844.32452-7-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  • Loading branch information
dagrh committed Feb 28, 2017
1 parent e2fa71f commit 67f11b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions exec.c
Expand Up @@ -1524,6 +1524,19 @@ size_t qemu_ram_pagesize(RAMBlock *rb)
return rb->page_size;
}

/* Returns the largest size of page in use */
size_t qemu_ram_pagesize_largest(void)
{
RAMBlock *block;
size_t largest = 0;

QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
largest = MAX(largest, qemu_ram_pagesize(block));
}

return largest;
}

static int memory_try_enable_merging(void *addr, size_t len)
{
if (!machine_mem_merge(current_machine)) {
Expand Down
1 change: 1 addition & 0 deletions include/exec/cpu-common.h
Expand Up @@ -64,6 +64,7 @@ void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
void qemu_ram_unset_idstr(RAMBlock *block);
const char *qemu_ram_get_idstr(RAMBlock *rb);
size_t qemu_ram_pagesize(RAMBlock *block);
size_t qemu_ram_pagesize_largest(void);

void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
int len, int is_write);
Expand Down
1 change: 1 addition & 0 deletions include/migration/migration.h
Expand Up @@ -93,6 +93,7 @@ struct MigrationIncomingState {
*/
QemuEvent main_thread_load_event;

size_t largest_page_size;
bool have_fault_thread;
QemuThread fault_thread;
QemuSemaphore fault_thread_sem;
Expand Down
1 change: 1 addition & 0 deletions migration/migration.c
Expand Up @@ -387,6 +387,7 @@ static void process_incoming_migration_co(void *opaque)
int ret;

mis->from_src_file = f;
mis->largest_page_size = qemu_ram_pagesize_largest();
postcopy_state_set(POSTCOPY_INCOMING_NONE);
migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
MIGRATION_STATUS_ACTIVE);
Expand Down

0 comments on commit 67f11b5

Please sign in to comment.