migratioin/ram.c: reset complete_round when we gets a queued page
PATCH 1/1 migratioin/ram.c: reset complete_round when we gets a queued page
In case we gets a queued page, the order of block is interrupted. We may not rely on the complete_round flag to say we have already searched the whole blocks on the list.
--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)
migration/ram.c +6 -0
@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare. +*/ + pss->complete_round = false; }return !!block;
Signature · 1 line
2.19.1
Quoted 14 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)migration/ram.c +0
-0
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 7 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare.
Why this is needed? Could you help explain the problem first?
Thanks,
Signature · 1 line
Peter Xu
Quoted 10 lines · Peter Xu
Quoted 9 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 14 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 12 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare. Why this is needed? Could you help explain the problem first?
Peter, Thanks for your question.
I found this issue during code review and I believe this is a corner case.
Below is a draft chart for ram_find_and_save_block:
ram_find_and_save_block
do
get_queued_page()
find_dirty_block()
ram_save_host_page()
while
The basic logic here is : get a page need to migrate and migrate it.
In case we don't have get_queued_page(), find_dirty_block() will search the whole ram_list.blocks by order. pss->complete_round is used to indicate whether this search has looped.
Everything works fine after get_queued_page() involved. The block unqueued in get_queued_page() could be any block in the ram_list.blocks. This means we have very little chance to break the looped indicator.
unqueue_page() last_seen_block
| |
ram_list.blocks v v
---------------------------------+=====+---Just draw a raw picture to demonstrate a corner case.
For example, we start from last_seen_block and search till the end of ram_list.blocks. At this moment, pss->complete_round is set to true. Then we get a queued page from unqueue_page() at the point I pointed. So the loop continues may just continue the range as I marked as "=". We will skip all the other ranges.
This is really a corner case, since ram_save_host_page() should return 0 and there should be no dirty page in this range. But I don't see we may avoid this case.
If I am not correct, just let me know :-)
Quoted 5 lines
Thanks,
Signature · 1 line
Peter Xu
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 55 lines · Wei Yang
Quoted 10 lines · Peter Xu
Quoted 9 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 14 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 12 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare. Why this is needed? Could you help explain the problem first?
Peter, Thanks for your question.
I found this issue during code review and I believe this is a corner case.
Below is a draft chart for
ram_find_and_save_block:
ram_find_and_save_block
do
get_queued_page()
find_dirty_block()
ram_save_host_page()
whileThe basic logic here is : get a page need to migrate and migrate it.
In case we don't have
get_queued_page(),find_dirty_block()will search the whole ram_list.blocks by order.pss->complete_roundis used to indicate whether this search has looped.Everything works fine after
get_queued_page()involved. The block unqueued inget_queued_page()could be any block in the ram_list.blocks. This means we have very little chance to break the looped indicator.unqueue_page() last_seen_block | | ram_list.blocks v v ---------------------------------+=====+---
Quoted 7 lines
Just draw a raw picture to demonstrate a corner case.
For example, we start from
last_seen_blockand search till the end of ram_list.blocks. At this moment,pss->complete_roundis set to true. Then we get a queued page fromunqueue_page()at the point I pointed. So the loop continues may just continue the range as I marked as "=". We will skip all the other ranges.
Ah I see your point, but I don't think there is a problem - note that complete_round will be reset for each ram_find_and_save_block(), so even if we have that iteration of ram_find_and_save_block() to return we'll still know we have dirty pages to migrate and in the next call we'll be fine, no?
Signature · 1 line
Peter Xu
Juan Quintela
Reviewed-byQuoted 27 lines · Peter Xu
Quoted 11 lines · Wei Yang
Quoted 10 lines · Peter Xu
Quoted 9 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
migration/ram.c +0
-0Quoted 9 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 8 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare.
Quoted 5 lines
Ah I see your point, but I don't think there is a problem - note that
complete_roundwill be reset for eachram_find_and_save_block(), so even if we have that iteration ofram_find_and_save_block()to return we'll still know we have dirty pages to migrate and in the next call we'll be fine, no?
I *think* that peter is perhaps right, but it is not clear at all, and it is easier to be safe. I think that the only case that this could matter is if:
- all pages are clean (so complete_round will get as true)
- we went a queue_page request
Is that possible? I am not completely sure after looking at the code. It *could* be if the page that got queued is the last page remaining, but ...... I fully agree that the case that _almost all_ pages are clean and we get a request for a queued page is really rare, so it should not matter in real life, but ....
Later, Juan.
Quoted 42 lines · Juan Quintela
Quoted 27 lines · Peter Xu
Quoted 11 lines · Wei Yang
Quoted 10 lines · Peter Xu
Quoted 9 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
migration/ram.c +0
-0Quoted 9 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 8 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare. Quoted 5 lines
Ah I see your point, but I don't think there is a problem - note that
complete_roundwill be reset for eachram_find_and_save_block(), so even if we have that iteration ofram_find_and_save_block()to return we'll still know we have dirty pages to migrate and in the next call we'll be fine, no?Reviewed-by Juan Quintela <[email protected]>I *think* that peter is perhaps right, but it is not clear at all, and it is easier to be safe. I think that the only case that this could matter is if:
- all pages are clean (socomplete_roundwill get as true)
- we went aqueue_pagerequest
Quoted 6 lines
Is that possible? I am not completely sure after looking at the code. It *could* be if the page that got queued is the last page remaining, but ...... I fully agree that the case that
_almostall_pages are clean and we get a request for a queued page is really rare, so it should not matter in real life, but ....
Agree
Quoted 1 line
Later, Juan.
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 64 lines · Peter Xu
Quoted 55 lines · Wei Yang
Quoted 10 lines · Peter Xu
Quoted 9 lines · Wei Yang
In case we gets a queued page, the order of block is interrupted. We may not rely on the
complete_roundflag to say we have already searched the whole blocks on the list.Signed-off-by Wei Yang <[email protected]>--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 14 lines
migration/ram.c static bool get_queued_page(RAMState *rs, PageSearchStatus *pss) · line 2296
Quoted 12 lines
migration/ram.c +4
-0@@ -2290,6 +2290,12 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)*/ pss->block = block; pss->page = offset >>TARGET_PAGE_BITS ; + +/* +* This unqueued page would break the "one round" check, even is +* really rare. Why this is needed? Could you help explain the problem first?
Peter, Thanks for your question.
I found this issue during code review and I believe this is a corner case.
Below is a draft chart for
ram_find_and_save_block:
ram_find_and_save_block
do
get_queued_page()
find_dirty_block()
ram_save_host_page()
whileThe basic logic here is : get a page need to migrate and migrate it.
In case we don't have
get_queued_page(),find_dirty_block()will search the whole ram_list.blocks by order.pss->complete_roundis used to indicate whether this search has looped.Everything works fine after
get_queued_page()involved. The block unqueued inget_queued_page()could be any block in the ram_list.blocks. This means we have very little chance to break the looped indicator.unqueue_page() last_seen_block | | ram_list.blocks v v ---------------------------------+=====+---Quoted 7 lines
Just draw a raw picture to demonstrate a corner case.
For example, we start from
last_seen_blockand search till the end of ram_list.blocks. At this moment,pss->complete_roundis set to true. Then we get a queued page fromunqueue_page()at the point I pointed. So the loop continues may just continue the range as I marked as "=". We will skip all the other ranges.
Quoted 6 lines
Ah I see your point, but I don't think there is a problem - note that
complete_roundwill be reset for eachram_find_and_save_block(), so even if we have that iteration ofram_find_and_save_block()to return we'll still know we have dirty pages to migrate and in the next call we'll be fine, no?
This is really a rare case and hard to say whether it would be harmful.
The chance still exists.
Quoted 2 lines
Signature · 1 line
Peter Xu
Signature · 2 lines
Wei Yang Help you, Help me
migratioin -> migration
Quoted 1 line · Philippe Mathieu-Daud??
migratioin -> migration
Ah... I should take an English lesson...
Thanks
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 4 lines · Wei Yang
Quoted 1 line · Philippe Mathieu-Daud??
migratioin -> migration
Ah... I should take an English lesson...
Your English is fine, I believe this is just a typo that slipped in ;)