[RFC PATCH] migration/ram: avoid to do log clear in the last round

Yanfei Xu posted 1 patch 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250514102733.3114824-1-yanfei.xu@bytedance.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
There is a newer version of this series
migration/ram.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[RFC PATCH] migration/ram: avoid to do log clear in the last round
Posted by Yanfei Xu 6 months ago
There won't be any ram sync after the stage of save_complete, therefore
it's unnecessary to do manually protect for dirty pages being sent. Skip
to do this in last round can reduce noticeable downtime.

Signed-off-by: Yanfei Xu <yanfei.xu@bytedance.com>
---
As I don't have proper machine to test this patch in qemu and verify if it has
risks like in postcopy, colo and so on.(But I tested this idea on my rust VMM,
it works and can reduce ~50ms for a 128GB guest). So I raise the patch with RFC
for suggestions.

 migration/ram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index e12913b43e..2b169cdd18 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -838,7 +838,9 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
      * the page in the chunk we clear the remote dirty bitmap for all.
      * Clearing it earlier won't be a problem, but too late will.
      */
-    migration_clear_memory_region_dirty_bitmap(rb, page);
+    if (!rs->last_stage) {
+        migration_clear_memory_region_dirty_bitmap(rb, page);
+    }
 
     ret = test_and_clear_bit(page, rb->bmap);
     if (ret) {
-- 
2.20.1
Re: [RFC PATCH] migration/ram: avoid to do log clear in the last round
Posted by Yanfei Xu 6 months ago
Please ingore this email and reply to the later identical one (sent 
about 1 hour later). The duplicate was cause by the network latency - 
sorry for the noise.

Thanks,
Yanfei

On 2025/5/14 18:27, Yanfei Xu wrote:
> There won't be any ram sync after the stage of save_complete, therefore
> it's unnecessary to do manually protect for dirty pages being sent. Skip
> to do this in last round can reduce noticeable downtime.
>
> Signed-off-by: Yanfei Xu <yanfei.xu@bytedance.com>
> ---
> As I don't have proper machine to test this patch in qemu and verify if it has
> risks like in postcopy, colo and so on.(But I tested this idea on my rust VMM,
> it works and can reduce ~50ms for a 128GB guest). So I raise the patch with RFC
> for suggestions.
>
>   migration/ram.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index e12913b43e..2b169cdd18 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -838,7 +838,9 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
>        * the page in the chunk we clear the remote dirty bitmap for all.
>        * Clearing it earlier won't be a problem, but too late will.
>        */
> -    migration_clear_memory_region_dirty_bitmap(rb, page);
> +    if (!rs->last_stage) {
> +        migration_clear_memory_region_dirty_bitmap(rb, page);
> +    }
>   
>       ret = test_and_clear_bit(page, rb->bmap);
>       if (ret) {