From: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxx> Detecting zero page is not a light work, we can disable it for compression that can handle all zero data very well Signed-off-by: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxx> --- migration/ram.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 80914b747e..15b20d3f70 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1760,15 +1760,30 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, return res; } - /* - * When starting the process of a new block, the first page of - * the block should be sent out before other pages in the same - * block, and all the pages in last block should have been sent - * out, keeping this order is important, because the 'cont' flag - * is used to avoid resending the block name. - */ - if (block != rs->last_sent_block && save_page_use_compression(rs)) { + if (save_page_use_compression(rs)) { + /* + * When starting the process of a new block, the first page of + * the block should be sent out before other pages in the same + * block, and all the pages in last block should have been sent + * out, keeping this order is important, because the 'cont' flag + * is used to avoid resending the block name. + * + * We post the fist page as normal page as compression will take + * much CPU resource. + */ + if (block != rs->last_sent_block) { flush_compressed_data(rs); + } else { + /* + * do not detect zero page as it can be handled very well + * for compression + */ + res = compress_page_with_multi_thread(rs, block, offset); + if (res > 0) { + return res; + } + compression_counters.busy++; + } } res = save_zero_page(rs, block, offset); @@ -1785,19 +1800,6 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, return res; } - /* - * Make sure the first page is sent out before other pages. - * - * we post it as normal page as compression will take much - * CPU resource. - */ - if (block == rs->last_sent_block && save_page_use_compression(rs)) { - res = compress_page_with_multi_thread(rs, block, offset); - if (res > 0) { - return res; - } - compression_counters.busy++; - } return ram_save_page(rs, pss, last_stage); } -- 2.14.4