qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-3.0 1/9] migration: simplify check to use qe


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH for-3.0 1/9] migration: simplify check to use qemu file buffer
Date: Thu, 5 Jul 2018 10:01:09 +0100
User-agent: Mutt/1.10.0 (2018-05-17)

* Peter Xu (address@hidden) wrote:
> Firstly, renaming the old matching_page_sizes variable to
> matching_target_page_size, which suites more to what it did (it only
> checks against target page size rather than multiple page sizes).
> Meanwhile, simplify the check logic a bit, and enhance the comments.
> Should have no functional change.
> 
> Signed-off-by: Peter Xu <address@hidden>
> ---
>  migration/ram.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 23cea47090..fbeb23f750 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -3580,7 +3580,7 @@ static int ram_load_postcopy(QEMUFile *f)
>  {
>      int flags = 0, ret = 0;
>      bool place_needed = false;
> -    bool matching_page_sizes = false;
> +    bool matching_target_page_size = false;
>      MigrationIncomingState *mis = migration_incoming_get_current();
>      /* Temporary page that is later 'placed' */
>      void *postcopy_host_page = postcopy_get_tmp_page(mis);
> @@ -3620,7 +3620,7 @@ static int ram_load_postcopy(QEMUFile *f)
>                  ret = -EINVAL;
>                  break;
>              }
> -            matching_page_sizes = block->page_size == TARGET_PAGE_SIZE;
> +            matching_target_page_size = block->page_size == TARGET_PAGE_SIZE;

That's OK, although 'matches_target_page_size' would be better wording.
('matching_target_page_size' implies we know something about the sources
target page size)

>              /*
>               * Postcopy requires that we place whole host pages atomically;
>               * these may be huge pages for RAMBlocks that are backed by
> @@ -3668,12 +3668,17 @@ static int ram_load_postcopy(QEMUFile *f)
>  
>          case RAM_SAVE_FLAG_PAGE:
>              all_zero = false;
> -            if (!place_needed || !matching_page_sizes) {
> +            if (!matching_target_page_size) {
> +                /* For huge pages, we always use temporary buffer */
>                  qemu_get_buffer(f, page_buffer, TARGET_PAGE_SIZE);
>              } else {
> -                /* Avoids the qemu_file copy during postcopy, which is
> -                 * going to do a copy later; can only do it when we
> -                 * do this read in one go (matching page sizes)
> +                /*
> +                 * For small pages that matches target page size, we
> +                 * avoid the qemu_file copy.  Instead we directly use
> +                 * the buffer of QEMUFile to place the page.  Note: we
> +                 * cannot do any QEMUFile operation before using that
> +                 * buffer to make sure the buffer is valid when
> +                 * placing the page.
>                   */
>                  qemu_get_buffer_in_place(f, (uint8_t **)&place_source,
>                                           TARGET_PAGE_SIZE);

But, yes I think that's right; since this is in ram_load_postcopy
the only time we have !place_needed is in the not-last subpage of a 
hugepage (or host page > target_page), so that's already covered
by the !matching_page_sizes check.


Reviewed-by: Dr. David Alan Gilbert <address@hidden>

> -- 
> 2.17.1
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]