diff mbox series

[2/2] migration/postcopy: use QEMU_IS_ALIGNED to replace host_offset

Message ID 20190806004648.8659-3-richardw.yang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series migration/postcopy: simplify postcopy_chunk_hostpages_pass | expand

Commit Message

Wei Yang Aug. 6, 2019, 12:46 a.m. UTC
Use QEMU_IS_ALIGNED for the check, it would be more consistent with
other align calculations.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/ram.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Dr. David Alan Gilbert Aug. 6, 2019, 3:47 p.m. UTC | #1
* Wei Yang (richardw.yang@linux.intel.com) wrote:
> Use QEMU_IS_ALIGNED for the check, it would be more consistent with
> other align calculations.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/ram.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index d86661a015..dfbf71c580 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2956,14 +2956,12 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
>      }
>  
>      while (run_start < pages) {
> -        unsigned long host_offset;
>  
>          /*
>           * If the start of this run of pages is in the middle of a host
>           * page, then we need to fixup this host page.
>           */
> -        host_offset = run_start % host_ratio;
> -        if (!host_offset) {
> +        if (QEMU_IS_ALIGNED(run_start, host_ratio)) {
>              /* Find the end of this run */
>              if (unsent_pass) {
>                  run_start = find_next_bit(unsentmap, pages, run_start + 1);
> @@ -2975,10 +2973,9 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
>               * run doesn't finish at the end of a host page
>               * and we need to discard.
>               */
> -            host_offset = run_start % host_ratio;
>          }
>  
> -        if (host_offset) {
> +        if (!QEMU_IS_ALIGNED(run_start, host_ratio)) {
>              unsigned long page;
>              unsigned long fixup_start_addr = QEMU_ALIGN_DOWN(run_start,
>                                                               host_ratio);
> -- 
> 2.17.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index d86661a015..dfbf71c580 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2956,14 +2956,12 @@  static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
     }
 
     while (run_start < pages) {
-        unsigned long host_offset;
 
         /*
          * If the start of this run of pages is in the middle of a host
          * page, then we need to fixup this host page.
          */
-        host_offset = run_start % host_ratio;
-        if (!host_offset) {
+        if (QEMU_IS_ALIGNED(run_start, host_ratio)) {
             /* Find the end of this run */
             if (unsent_pass) {
                 run_start = find_next_bit(unsentmap, pages, run_start + 1);
@@ -2975,10 +2973,9 @@  static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
              * run doesn't finish at the end of a host page
              * and we need to discard.
              */
-            host_offset = run_start % host_ratio;
         }
 
-        if (host_offset) {
+        if (!QEMU_IS_ALIGNED(run_start, host_ratio)) {
             unsigned long page;
             unsigned long fixup_start_addr = QEMU_ALIGN_DOWN(run_start,
                                                              host_ratio);