migration/postcopy: cleanup function postcopy_send_discard_bm_ram
cover migration/postcopy: cleanup function postcopy_send_discard_bm_ram
Some cleanup of function postcopy_send_discard_bm_ram:
* use a more restrict check for discard page
* break the loop when no more page to discard
* it is for sure discard_length is not 0
No functional change.
Wei Yang (3):
migration/postcopy: the valid condition is one less then end migration/postcopy: break the loop when there is no more page to
discard
migration/postcopy: discard_length must not be 0
migration/ram.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
Signature · 1 line
2.19.1
PATCH 1/3 migration/postcopy: the valid condition is one less then end
If one equals end, it means we have gone through the whole bitmap.
Use a more restrict check to skip a unnecessary condition.
--- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
migration/ram.c +1 -1
@@ -2777,7 +2777,7 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms,for (current =0 ; current < end; ) {unsigned long one =find_next_bit (unsentmap, end, current); -if (one <= end) { +if (one < end) {unsigned long zero =find_next_zero_bit (unsentmap, end, one +1 );unsigned long discard_length;
Signature · 1 line
2.19.1
Re: [Qemu-devel] [PATCH 1/3] migration/postcopy: the valid condition is one less then end
Quoted 5 lines · * Wei Yang ([email protected]) wrote:
If one equals end, it means we have gone through the whole bitmap.
Use a more restrict check to skip a unnecessary condition.
Signed-off-by Wei Yang <[email protected]>
Yes, I don't think that'll break, since I think the find_next_zero_bit will also return end, and then discard_length would be 0; still I think it's a correct fix.
Quoted 20 lines
--- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/ram.c +1
-1@@ -2777,7 +2777,7 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms,for (current =0 ; current < end; ) {unsigned long one =find_next_bit (unsentmap, end, current); -if (one <= end) { +if (one < end) {unsigned long zero =find_next_zero_bit (unsentmap, end, one +1 );unsigned long discard_length;Signature · 1 line
2.19.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 1/3] migration/postcopy: the valid condition is one less then end
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Wei Yang ([email protected]) wrote:
If one equals end, it means we have gone through the whole bitmap.
Use a more restrict check to skip a unnecessary condition.
Signed-off-by Wei Yang <[email protected]>Yes, I don't think that'll break, since I think the
find_next_zero_bitwill also return end, and thendiscard_lengthwould be 0; still I think it's a correct fix.
Yep, you are exactly right.
Quoted 25 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 20 lines
--- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/ram.c +1
-1@@ -2777,7 +2777,7 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms,for (current =0 ; current < end; ) {unsigned long one =find_next_bit (unsentmap, end, current); -if (one <= end) { +if (one < end) {unsigned long zero =find_next_zero_bit (unsentmap, end, one +1 );unsigned long discard_length;Signature · 1 line
2.19.1--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 2 lines
Wei Yang Help you, Help me
PATCH 2/3 migration/postcopy: break the loop when there is no more page to discard
In reply to Wei YangWhen one is equal or bigger then end, it means there is no page to discard. Just break the loop in this case instead of processing it.
No functional change, just refactor it a little.
--- migration/ram.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
migration/ram.c +13 -13
@@ -2776,23 +2776,23 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms,for (current =0 ; current < end; ) {unsigned long one =find_next_bit (unsentmap, end, current); +unsigned long zero, discard_length; -if (one < end) { -unsigned long zero =find_next_zero_bit (unsentmap, end, one +1 ); -unsigned long discard_length; +if (one >= end) { +break ; + } -if (zero >= end) { - discard_length = end - one; - }else { - discard_length = zero - one; - } -if (discard_length) { -postcopy_discard_send_range (ms, pds, one, discard_length); - } - current = one + discard_length; + zero =find_next_zero_bit (unsentmap, end, one +1 ); + +if (zero >= end) { + discard_length = end - one; }else { - current = one; + discard_length = zero - one; + } +if (discard_length) { +postcopy_discard_send_range (ms, pds, one, discard_length); } + current = one + discard_length; }return 0 ;
Signature · 1 line
2.19.1
Re: [Qemu-devel] [PATCH 2/3] migration/postcopy: break the loop when there is no more page to discard
Quoted 6 lines · * Wei Yang ([email protected]) wrote:
When one is equal or bigger then end, it means there is no page to discard. Just break the loop in this case instead of processing it.
No functional change, just refactor it a little.
Signed-off-by Wei Yang <[email protected]>
Quoted 48 lines
--- migration/ram.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)migration/ram.c +13
-13@@ -2776,23 +2776,23 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms,for (current =0 ; current < end; ) {unsigned long one =find_next_bit (unsentmap, end, current); +unsigned long zero, discard_length; -if (one < end) { -unsigned long zero =find_next_zero_bit (unsentmap, end, one +1 ); -unsigned long discard_length; +if (one >= end) { +break ; + } -if (zero >= end) { - discard_length = end - one; - }else { - discard_length = zero - one; - } -if (discard_length) { -postcopy_discard_send_range (ms, pds, one, discard_length); - } - current = one + discard_length; + zero =find_next_zero_bit (unsentmap, end, one +1 ); + +if (zero >= end) { + discard_length = end - one; }else { - current = one; + discard_length = zero - one; + } +if (discard_length) { +postcopy_discard_send_range (ms, pds, one, discard_length); } + current = one + discard_length; }return 0 ;Signature · 1 line
2.19.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 3/3 migration/postcopy: discard_length must not be 0
In reply to Wei YangSince we break the loop when there is no more page to discard, we are sure the following process would find some page to discard.
It is not necessary to check it again.
--- migration/ram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
migration/ram.c +1 -3
@@ -2789,9 +2789,7 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms, }else { discard_length = zero - one; } -if (discard_length) { -postcopy_discard_send_range (ms, pds, one, discard_length); - } +postcopy_discard_send_range (ms, pds, one, discard_length); current = one + discard_length; }
Signature · 1 line
2.19.1
Re: [Qemu-devel] [PATCH 3/3] migration/postcopy: discard_length must not be 0
Quoted 6 lines · * Wei Yang ([email protected]) wrote:
Since we break the loop when there is no more page to discard, we are sure the following process would find some page to discard.
It is not necessary to check it again.
Signed-off-by Wei Yang <[email protected]>
Quoted 22 lines
--- migration/ram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)migration/ram.c +1
-3@@ -2789,9 +2789,7 @@ static int postcopy_send_discard_bm_ram(MigrationState *ms, }else { discard_length = zero - one; } -if (discard_length) { -postcopy_discard_send_range (ms, pds, one, discard_length); - } +postcopy_discard_send_range (ms, pds, one, discard_length); current = one + discard_length; }Signature · 1 line
2.19.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 8 lines · * Wei Yang ([email protected]) wrote:
Some cleanup of function
postcopy_send_discard_bm_ram:* use a more restrict check for discard page
* break the loop when no more page to discard
* it is for surediscard_lengthis not 0No functional change.
Queued
Quoted 6 lines
Wei Yang (3):
migration/postcopy: the valid condition is one less then end migration/postcopy: break the loop when there is no more page to
discard
migration/postcopy:discard_lengthmust not be 0
Quoted 7 lines
migration/ram.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)Signature · 1 line
2.19.1
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK