Skip to contentSkip to conversation

migration/postcopy: cleanup function postcopy_chunk_hostpages_pass

PATCH In review Wei Yang 2 participants 6 messages Jul 10, 2019 – Aug 7, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover migration/postcopy: cleanup function postcopy_chunk_hostpages_pass

Here are two trivial function cleanup.

BTW, I didn't test them since TPS == HPS. How could I setup a guest with TPS != HPS?

Wei Yang (2):
migration/postcopy: reduce one operation to calculate fixup_start_addr migration/postcopy: do_fixup is true when host_offset is non-zero

 migration/ram.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 migration/postcopy: reduce one operation to calculate fixup_start_addr

Use the same way for run_end to calculate run_start, which saves one operation.

---
 migration/ram.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
migration/ram.c +6 -4
index 410e0f89fe..c4dc36e525 100644
@@ -2884,10 +2884,12 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
         host_offset = run_start % host_ratio;
         if (host_offset) {
             do_fixup = true;
-            run_start -= host_offset;
-            fixup_start_addr = run_start;
-            /* For the next pass */
-            run_start = run_start + host_ratio;
+            fixup_start_addr = run_start - host_offset;
+            /*
+             * This host page has gone, the next loop iteration starts
+             * from after the fixup
+             */
+            run_start = fixup_start_addr + host_ratio;
         } else {
             /* Find the end of this run */
             unsigned long run_end;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] migration/postcopy: reduce one operation to calculate fixup_start_addr

Quoted 4 lines · * Wei Yang ([email protected]) wrote:

Use the same way for run_end to calculate run_start, which saves one operation.

Quoted 28 lines
---
 migration/ram.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
migration/ram.c +6 -4
index 410e0f89fe..c4dc36e525 100644
@@ -2884,10 +2884,12 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
         host_offset = run_start % host_ratio;
         if (host_offset) {
             do_fixup = true;
-            run_start -= host_offset;
-            fixup_start_addr = run_start;
-            /* For the next pass */
-            run_start = run_start + host_ratio;
+            fixup_start_addr = run_start - host_offset;
+            /*
+             * This host page has gone, the next loop iteration starts
+             * from after the fixup
+             */
+            run_start = fixup_start_addr + host_ratio;
         } else {
             /* Find the end of this run */
             unsigned long run_end;
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

author
#3 lore raw

PATCH 2/2 migration/postcopy: do_fixup is true when host_offset is non-zero

In reply to Wei Yang

This means it is not necessary to spare an extra variable to hold this condition. Use host_offset directly is fine.

---
 migration/ram.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
migration/ram.c +1 -4
index c4dc36e525..b0ca0059c4 100644
@@ -2873,7 +2873,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
     }
 
     while (run_start < pages) {
-        bool do_fixup = false;
         unsigned long fixup_start_addr;
         unsigned long host_offset;
 
@@ -2883,7 +2882,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
          */
         host_offset = run_start % host_ratio;
         if (host_offset) {
-            do_fixup = true;
             fixup_start_addr = run_start - host_offset;
             /*
              * This host page has gone, the next loop iteration starts
@@ -2905,7 +2903,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
              */
             host_offset = run_end % host_ratio;
             if (host_offset) {
-                do_fixup = true;
                 fixup_start_addr = run_end - host_offset;
                 /*
                  * This host page has gone, the next loop iteration starts
@@ -2921,7 +2918,7 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
             }
         }
 
-        if (do_fixup) {
+        if (host_offset) {
             unsigned long page;
 
             /* Tell the destination to discard this page */
Signature · 1 line
2.17.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] migration/postcopy: do_fixup is true when host_offset is non-zero

Quoted 4 lines · * Wei Yang ([email protected]) wrote:

This means it is not necessary to spare an extra variable to hold this condition. Use host_offset directly is fine.

Quoted 44 lines
---
 migration/ram.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
migration/ram.c +1 -4
index c4dc36e525..b0ca0059c4 100644
@@ -2873,7 +2873,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
     }
 
     while (run_start < pages) {
-        bool do_fixup = false;
         unsigned long fixup_start_addr;
         unsigned long host_offset;
 
@@ -2883,7 +2882,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
          */
         host_offset = run_start % host_ratio;
         if (host_offset) {
-            do_fixup = true;
             fixup_start_addr = run_start - host_offset;
             /*
              * This host page has gone, the next loop iteration starts
@@ -2905,7 +2903,6 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
              */
             host_offset = run_end % host_ratio;
             if (host_offset) {
-                do_fixup = true;
                 fixup_start_addr = run_end - host_offset;
                 /*
                  * This host page has gone, the next loop iteration starts
@@ -2921,7 +2918,7 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass,
             }
         }
 
-        if (do_fixup) {
+        if (host_offset) {
             unsigned long page;
 
             /* Tell the destination to discard this page */
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#5 lore raw
In reply to Wei Yang
Quoted 1 line · * Wei Yang ([email protected]) wrote:

Here are two trivial function cleanup.

Queued

Quoted 14 lines

BTW, I didn't test them since TPS == HPS. How could I setup a guest with TPS != HPS?

Wei Yang (2):
migration/postcopy: reduce one operation to calculate fixup_start_addr migration/postcopy: do_fixup is true when host_offset is non-zero

 migration/ram.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK