* Peter Xu (peterx@redhat.com) wrote:
> Let it replace the old qemu_ram_pagesize_largest() just to fetch the page
> sizes using migration_ram_pagesize(), because it'll start to consider
> double mapping effect in migrations.
>
> Also don't account the ignored ramblocks as they won't be migrated.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> include/exec/cpu-common.h | 1 -
> migration/migration.c | 2 +-
> migration/ram.c | 12 ++++++++++++
> migration/ram.h | 1 +
> softmmu/physmem.c | 13 -------------
> 5 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 94452aa17f..4c394ccdfc 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -96,7 +96,6 @@ int qemu_ram_get_fd(RAMBlock *rb);
>
> size_t qemu_ram_pagesize(RAMBlock *block);
> bool qemu_ram_is_hugetlb(RAMBlock *rb);
> -size_t qemu_ram_pagesize_largest(void);
>
> /**
> * cpu_address_space_init:
> diff --git a/migration/migration.c b/migration/migration.c
> index f6fe474fc3..7724e00c47 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -604,7 +604,7 @@ process_incoming_migration_co(void *opaque)
>
> assert(mis->from_src_file);
> mis->migration_incoming_co = qemu_coroutine_self();
> - mis->largest_page_size = qemu_ram_pagesize_largest();
> + mis->largest_page_size = migration_ram_pagesize_largest();
> postcopy_state_set(POSTCOPY_INCOMING_NONE);
> migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
> MIGRATION_STATUS_ACTIVE);
> diff --git a/migration/ram.c b/migration/ram.c
> index 945c6477fd..2ebf414f5f 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -135,6 +135,18 @@ size_t migration_ram_pagesize(RAMBlock *block)
> return qemu_ram_pagesize(block);
> }
>
> +size_t migration_ram_pagesize_largest(void)
> +{
> + RAMBlock *block;
> + size_t largest = 0;
> +
> + RAMBLOCK_FOREACH_NOT_IGNORED(block) {
> + largest = MAX(largest, migration_ram_pagesize(block));
> + }
> +
> + return largest;
> +}
> +
> static void XBZRLE_cache_lock(void)
> {
> if (migrate_use_xbzrle()) {
> diff --git a/migration/ram.h b/migration/ram.h
> index 162b3e7cb8..cefe166841 100644
> --- a/migration/ram.h
> +++ b/migration/ram.h
> @@ -69,6 +69,7 @@ bool ramblock_is_ignored(RAMBlock *block);
>
> int xbzrle_cache_resize(uint64_t new_size, Error **errp);
> size_t migration_ram_pagesize(RAMBlock *block);
> +size_t migration_ram_pagesize_largest(void);
> uint64_t ram_bytes_remaining(void);
> uint64_t ram_bytes_total(void);
> void mig_throttle_counter_reset(void);
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index cdda7eaea5..536c204811 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -1813,19 +1813,6 @@ bool qemu_ram_is_hugetlb(RAMBlock *rb)
> return rb->page_size > qemu_real_host_page_size();
> }
>
> -/* Returns the largest size of page in use */
> -size_t qemu_ram_pagesize_largest(void)
> -{
> - RAMBlock *block;
> - size_t largest = 0;
> -
> - RAMBLOCK_FOREACH(block) {
> - 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)) {
> --
> 2.37.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK