migration/postcopy: cleanup function postcopy_chunk_hostpages_pass
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
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
@@ -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
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_endto calculaterun_start, which saves one operation.Signed-off-by Wei Yang <[email protected]>
Quoted 28 lines
--- migration/ram.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)migration/ram.c +6
-4@@ -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
PATCH 2/2 migration/postcopy: do_fixup is true when host_offset is non-zero
In reply to Wei YangThis 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
@@ -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
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_offsetdirectly is fine.Signed-off-by Wei Yang <[email protected]>
Quoted 44 lines
--- migration/ram.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)migration/ram.c +1
-4@@ -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
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 calculatefixup_start_addrmigration/postcopy:do_fixupis true whenhost_offsetis non-zeromigration/ram.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)Signature · 1 line
2.17.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK