Some modification about ram_save_host_page()
v4 cover Some modification about ram_save_host_page()
Hi all,
This series include patches as below:
Patch 1:
- reduce unnecessary rate limiting in ram_save_host_page()
Patch 2:
- optimized ram_save_host_page() by using migration_bitmap_find_dirty() to find dirty pages
History:
v3 -> v4:
- Remove the modification to ram_save_host_page() comment [Peter Xu]
- Remove the renaming of tmppages
v2 -> v3:
- Reduce unnecessary rate limiting if nothing is sent in the current iteration [David Edmondson]
- Invert the body of the loop in ram_save_host_page() [David Edmondson]
v1 -> v2:
- Modify ram_save_host_page() comment [David Edmondson]
- Remove 'goto' [David Edmondson]
Kunkun Jiang (2):
migration/ram: Reduce unnecessary rate limiting
migration/ram: Optimize ram_save_host_page()
migration/ram.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
Signature · 1 line
2.23.0
PATCH v4 1/2 migration/ram: Reduce unnecessary rate limiting
When the host page is a huge page and something is sent in the current iteration, migration_rate_limit() should be executed. If not, it can be omitted.
--- migration/ram.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
migration/ram.c +7 -2
@@ -2015,8 +2015,13 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, pages += tmppages; pss->page++; -/* Allow rate limiting to happen in the middle of huge pages */ -migration_rate_limit (); +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + } }while ((pss->page & (pagesize_bits -1 )) &&offset_in_ramblock (pss->block, ((ram_addr_t )pss->page) <<TARGET_PAGE_BITS ));
Signature · 1 line
2.23.0
Re: [PATCH v4 1/2] migration/ram: Reduce unnecessary rate limiting
Quoted 18 lines · Kunkun Jiang
When the host page is a huge page and something is sent in the current iteration,
migration_rate_limit()should be executed. If not, it can be omitted.Signed-off-by Keqian Zhu <[email protected]>Signed-off-by Kunkun Jiang <[email protected]>Reviewed-by David Edmondson <[email protected]>--- migration/ram.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)migration/ram.c +0
-0@@ -2015,8 +2015,13 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, pages += tmppages;
migration/ram.c static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, · line 2024
Quoted 10 lines
migration/ram.c +7
-2pss->page++; -/* Allow rate limiting to happen in the middle of huge pages */ -migration_rate_limit (); +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + }
Sorry I'm still not a fan of this - I'd even prefer calling that once more just to make sure it won't be forgotten to be called.. Not to say it's merely a noop.
I'll leave this to Dave.. Maybe I'm too harsh! :)
Signature · 1 line
Peter Xu
Re: [PATCH v4 1/2] migration/ram: Reduce unnecessary rate limiting
Hi Peter,
Quoted 32 lines · Peter Xu
Quoted 18 lines · Kunkun Jiang
When the host page is a huge page and something is sent in the current iteration,
migration_rate_limit()should be executed. If not, it can be omitted.Signed-off-by Keqian Zhu <[email protected]>Signed-off-by Kunkun Jiang <[email protected]>Reviewed-by David Edmondson <[email protected]>--- migration/ram.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)migration/ram.c +0
-0@@ -2015,8 +2015,13 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, pages += tmppages;migration/ram.c static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, · line 2024
Quoted 10 lines
migration/ram.c +7
-2pss->page++; -/* Allow rate limiting to happen in the middle of huge pages */ -migration_rate_limit (); +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + }Sorry I'm still not a fan of this - I'd even prefer calling that once more just to make sure it won't be forgotten to be called.. Not to say it's merely a noop.
Quoted 2 lines
I'll leave this to Dave.. Maybe I'm too harsh! :)
You are very serious and meticulous. I like your character very much.😉 This patch was used to reviewed by David. So, I want to know what his opinion is.
@David
Hi David, what is your opinion on this patch?
Thanks,
Kunkun Jiang
Re: [PATCH v4 1/2] migration/ram: Reduce unnecessary rate limiting
Quoted 35 lines · Kunkun Jiang
Hi Peter,
Quoted 32 lines · Peter Xu
Quoted 18 lines · Kunkun Jiang
When the host page is a huge page and something is sent in the current iteration,
migration_rate_limit()should be executed. If not, it can be omitted.Signed-off-by Keqian Zhu <[email protected]>Signed-off-by Kunkun Jiang <[email protected]>Reviewed-by David Edmondson <[email protected]>--- migration/ram.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)migration/ram.c +0
-0@@ -2015,8 +2015,13 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, pages += tmppages;migration/ram.c static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, · line 2024
Quoted 10 lines
migration/ram.c +7
-2pss->page++; -/* Allow rate limiting to happen in the middle of huge pages */ -migration_rate_limit (); +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + }Sorry I'm still not a fan of this - I'd even prefer calling that once more just to make sure it won't be forgotten to be called.. Not to say it's merely a noop.
Quoted 8 lines
Quoted 2 lines
I'll leave this to Dave.. Maybe I'm too harsh! :)
You are very serious and meticulous. I like your character very much.😉 This patch was used to reviewed by David. So, I want to know what his opinion is.
@David
Hi David, what is your opinion on this patch?
I suspect that this referred to David Gilbert rather than me :-)
Quoted 2 lines
Thanks,
Kunkun Jiang
dme.
Signature · 1 line
Time is waiting to explain, why refuse?
Dr. David Alan Gilbert
Reviewed-byRe: [PATCH v4 1/2] migration/ram: Reduce unnecessary rate limiting
In reply to Kunkun JiangQuoted 34 lines · * Kunkun Jiang ([email protected]) wrote:
Hi Peter,
Quoted 31 lines · Peter Xu
Quoted 17 lines · Kunkun Jiang
When the host page is a huge page and something is sent in the current iteration,
migration_rate_limit()should be executed. If not, it can be omitted.Signed-off-by Keqian Zhu <[email protected]>Signed-off-by Kunkun Jiang <[email protected]>Reviewed-by David Edmondson <[email protected]>--- migration/ram.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)migration/ram.c +0
-0@@ -2015,8 +2015,13 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, pages += tmppages;migration/ram.c static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, · line 2023
Quoted 10 lines
migration/ram.c +7
-2pss->page++; -/* Allow rate limiting to happen in the middle of huge pages */ -migration_rate_limit (); +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + }Sorry I'm still not a fan of this - I'd even prefer calling that once more just to make sure it won't be forgotten to be called.. Not to say it's merely a noop.
Quoted 8 lines
Quoted 2 lines
I'll leave this to Dave.. Maybe I'm too harsh! :)
You are very serious and meticulous. I like your character very much.😉 This patch was used to reviewed by David. So, I want to know what his opinion is.
@David
Hi David, what is your opinion on this patch?
Yes, I think this is OK;
a) The qemu_file_rate_limit in the loop in ram_save_iterate still gets called, so that covers the 'pagesize_bits > 1' part of the if
b) As soon as we send any part of the hugepage the 'tmppages > 0' triggers and we get the check back again.
So I guess this mostly helps the case where we have big huge pages which are mostly not-dirty, and we spend a lot of time in ram_save_host_page searching for the target page to send.
Quoted 3 lines
Thanks,
Kunkun Jiang
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH v4 2/2 migration/ram: Optimize ram_save_host_page()
In reply to Kunkun JiangStarting from pss->page, ram_save_host_page() will check every page and send the dirty pages up to the end of the current host page or the boundary of used_length of the block. If the host page size is a huge page, the step "check" will take a lot of time.
It will improve performance to use migration_bitmap_find_dirty().
Tested on Kunpeng 920; VM parameters: 1U 4G (page size 1G) The time of ram_save_host_page() in the last round of ram saving:
before optimize: 9250us after optimize: 34us
--- migration/ram.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
migration/ram.c +19 -20
@@ -1993,6 +1993,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,int tmppages, pages =0 ;size_t pagesize_bits =qemu_ram_pagesize (pss->block) >>TARGET_PAGE_BITS ; +unsigned long hostpage_boundary = +QEMU_ALIGN_UP (pss->page +1 , pagesize_bits);unsigned long start_page = pss->page;int res;
@@ -2003,30 +2005,27 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,do {/* Check the pages is dirty and if it is send it */ -if (!migration_bitmap_clear_dirty (rs, pss->block, pss->page)) { - pss->page++; -continue ; - } - - tmppages =ram_save_target_page (rs, pss, last_stage); -if (tmppages <0 ) { -return tmppages; - } +if (migration_bitmap_clear_dirty (rs, pss->block, pss->page)) { + tmppages =ram_save_target_page (rs, pss, last_stage); +if (tmppages <0 ) { +return tmppages; + } - pages += tmppages; - pss->page++; -/* -* Allow rate limiting to happen in the middle of huge pages if -* something is sent in the current iteration. -*/ -if (pagesize_bits >1 && tmppages >0 ) { -migration_rate_limit (); + pages += tmppages; +/* +* Allow rate limiting to happen in the middle of huge pages if +* something is sent in the current iteration. +*/ +if (pagesize_bits >1 && tmppages >0 ) { +migration_rate_limit (); + } } - }while ((pss->page & (pagesize_bits -1 )) && + pss->page =migration_bitmap_find_dirty (rs, pss->block, pss->page); + }while ((pss->page < hostpage_boundary) &&offset_in_ramblock (pss->block, ((ram_addr_t )pss->page) <<TARGET_PAGE_BITS )); -/* The offset we leave with is the last one we looked at */ - pss->page--; +/* The offset we leave with is the min boundary of host page and block */ + pss->page =MIN (pss->page, hostpage_boundary) -1 ; res =ram_save_release_protection (rs, pss, start_page);return (res <0 ? res : pages);
Signature · 1 line
2.23.0
Re: [PATCH v4 2/2] migration/ram: Optimize ram_save_host_page()
Quoted 5 lines · Kunkun Jiang
Starting from
pss->page,ram_save_host_page()will check every page and send the dirty pages up to the end of the current host page or the boundary ofused_lengthof the block. If the host page size is a huge page, the step "check" will take a lot of time.
Quoted 8 lines
It will improve performance to use
migration_bitmap_find_dirty().Tested on Kunpeng 920; VM parameters: 1U 4G (page size 1G) The time of
ram_save_host_page()in the last round of ram saving:
before optimize: 9250us after optimize: 34usSigned-off-by Keqian Zhu <[email protected]>Signed-off-by Kunkun Jiang <[email protected]>
Thanks,
Signature · 1 line
Peter Xu
Kindly ping,
Hi David Alan Gilbert,
Will this series be picked up soon, or is there any other work for me to do?
Best Regards,
Kunkun Jiang
Quoted 31 lines · Kunkun Jiang
Hi all,
This series include patches as below:
Patch 1:
- reduce unnecessary rate limiting inram_save_host_page()Patch 2:
- optimizedram_save_host_page()by usingmigration_bitmap_find_dirty()to find dirty pagesHistory:
v3 -> v4:
- Remove the modification toram_save_host_page()comment [Peter Xu]
- Remove the renaming of tmppagesv2 -> v3:
- Reduce unnecessary rate limiting if nothing is sent in the current iteration [David Edmondson]
- Invert the body of the loop inram_save_host_page()[David Edmondson]v1 -> v2:
- Modifyram_save_host_page()comment [David Edmondson]
- Remove 'goto' [David Edmondson]Kunkun Jiang (2):
migration/ram: Reduce unnecessary rate limiting migration/ram: Optimizeram_save_host_page()migration/ram.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
Quoted 4 lines · * Kunkun Jiang ([email protected]) wrote:
Kindly ping,
Hi David Alan Gilbert,
Will this series be picked up soon, or is there any other work for me to do?
You don't need to do anything, but it did miss the cutoff for soft freeze; since it's an optimisation not a fix; it's still on my list so it'll go in just as soon as 6.1 opens up.
Dave
Quoted 36 lines
Best Regards,
Kunkun JiangQuoted 31 lines · Kunkun Jiang
Hi all,
This series include patches as below:
Patch 1:
- reduce unnecessary rate limiting inram_save_host_page()Patch 2:
- optimizedram_save_host_page()by usingmigration_bitmap_find_dirty()to find dirty pagesHistory:
v3 -> v4:
- Remove the modification toram_save_host_page()comment [Peter Xu]
- Remove the renaming of tmppagesv2 -> v3:
- Reduce unnecessary rate limiting if nothing is sent in the current iteration [David Edmondson]
- Invert the body of the loop inram_save_host_page()[David Edmondson]v1 -> v2:
- Modifyram_save_host_page()comment [David Edmondson]
- Remove 'goto' [David Edmondson]Kunkun Jiang (2):
migration/ram: Reduce unnecessary rate limiting migration/ram: Optimizeram_save_host_page()migration/ram.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Hi Dave,
Quoted 10 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Kunkun Jiang ([email protected]) wrote:
Kindly ping,
Hi David Alan Gilbert,
Will this series be picked up soon, or is there any other work for me to do?You don't need to do anything, but it did miss the cutoff for soft freeze; since it's an optimisation not a fix; it's still on my list so it'll go in just as soon as 6.1 opens up.
Dave
Okay, I see. Thank you.
Best Regards,
Kunkun Jiang
Quoted 35 lines
Quoted 35 lines
Best Regards,
Kunkun JiangQuoted 31 lines · Kunkun Jiang
Hi all,
This series include patches as below:
Patch 1:
- reduce unnecessary rate limiting inram_save_host_page()Patch 2:
- optimizedram_save_host_page()by usingmigration_bitmap_find_dirty()to find dirty pagesHistory:
v3 -> v4:
- Remove the modification toram_save_host_page()comment [Peter Xu]
- Remove the renaming of tmppagesv2 -> v3:
- Reduce unnecessary rate limiting if nothing is sent in the current iteration [David Edmondson]
- Invert the body of the loop inram_save_host_page()[David Edmondson]v1 -> v2:
- Modifyram_save_host_page()comment [David Edmondson]
- Remove 'goto' [David Edmondson]Kunkun Jiang (2):
migration/ram: Reduce unnecessary rate limiting migration/ram: Optimizeram_save_host_page()migration/ram.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
Quoted 1 line · * Kunkun Jiang ([email protected]) wrote:
Hi all,
Queued; sorry for the delay
Quoted 33 lines
This series include patches as below:
Patch 1:
- reduce unnecessary rate limiting inram_save_host_page()Patch 2:
- optimizedram_save_host_page()by usingmigration_bitmap_find_dirty()to find dirty pagesHistory:
v3 -> v4:
- Remove the modification toram_save_host_page()comment [Peter Xu]
- Remove the renaming of tmppagesv2 -> v3:
- Reduce unnecessary rate limiting if nothing is sent in the current iteration [David Edmondson]
- Invert the body of the loop inram_save_host_page()[David Edmondson]v1 -> v2:
- Modifyram_save_host_page()comment [David Edmondson]
- Remove 'goto' [David Edmondson]Kunkun Jiang (2):
migration/ram: Reduce unnecessary rate limiting
migration/ram: Optimizeram_save_host_page()migration/ram.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)Signature · 1 line
2.23.0
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK