[Patch v2] Don't sync volatile memory

Chaney, Ben posted 1 patch 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1CC43F59-336F-4A12-84AD-DB89E0A17A95@akamai.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
migration/ram.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Patch v2] Don't sync volatile memory
Posted by Chaney, Ben 5 months ago
Not all pmem regions are backed by non-volatile memory. Syncing volatile
memory provides no benefit, but can cause performance issues is some
cases. Only sync memory that is marked as non-volatile.

Signed-off-by: Ben Chaney <bchaney@akamai.com>
Fixes: bd108a44bc29 (migration: ram: Switch to ram block writeback)
---
migration/ram.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index d26dbd37c4..e857b579d6 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3672,7 +3672,9 @@ static int ram_load_cleanup(void *opaque)
     RAMBlock *rb;

     RAMBLOCK_FOREACH_NOT_IGNORED(rb) {
-        qemu_ram_block_writeback(rb);
+        if (memory_region_is_nonvolatile(rb->mr)) {
+            qemu_ram_block_writeback(rb);
+        }
     }

     xbzrle_load_cleanup();
--
2.40.1

Re: [Patch v2] Don't sync volatile memory
Posted by Peter Xu 5 months ago
On Mon, Jun 16, 2025 at 08:56:50PM +0000, Chaney, Ben wrote:
> Not all pmem regions are backed by non-volatile memory. Syncing volatile
> memory provides no benefit, but can cause performance issues is some
> cases. Only sync memory that is marked as non-volatile.
> 
> Signed-off-by: Ben Chaney <bchaney@akamai.com>
> Fixes: bd108a44bc29 (migration: ram: Switch to ram block writeback)

I've queued it with an update on the subject and commit message, as
following:

    migration: Don't sync volatile memory after migration completes
    
    Syncing volatile memory provides no benefit, instead it can cause
    performance issues in some cases.  Only sync memory that is marked as
    non-volatile after migration completes on destination.

Thanks,

> ---
> migration/ram.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index d26dbd37c4..e857b579d6 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -3672,7 +3672,9 @@ static int ram_load_cleanup(void *opaque)
>      RAMBlock *rb;
> 
>      RAMBLOCK_FOREACH_NOT_IGNORED(rb) {
> -        qemu_ram_block_writeback(rb);
> +        if (memory_region_is_nonvolatile(rb->mr)) {
> +            qemu_ram_block_writeback(rb);
> +        }
>      }
> 
>      xbzrle_load_cleanup();
> --
> 2.40.1
> 

-- 
Peter Xu