[PATCH v2 13/24] migration/postcopy: Send device states without copying buffer

Peter Xu posted 24 patches 1 week, 5 days ago
Maintainers: Hailiang Zhang <zhanghailiang@xfusion.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Markus Armbruster <armbru@redhat.com>
[PATCH v2 13/24] migration/postcopy: Send device states without copying buffer
Posted by Peter Xu 1 week, 5 days ago
Put buffer can be async as long as the flush happens before the buffer will
be recycled / reused.  Do it for postcopy package data.  Quick measurement
shows a small VM the time to push / flush the package shrinks from 91us to
38us.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 9d2109718a..d41e89228d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1136,7 +1136,8 @@ int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len)
     trace_qemu_savevm_send_packaged();
     qemu_savevm_command_send(f, MIG_CMD_PACKAGED, 4, (uint8_t *)&tmp);
 
-    qemu_put_buffer(f, buf, len);
+    /* We can use async put because the qemufile will be flushed right away */
+    qemu_put_buffer_async(f, buf, len, false);
     qemu_fflush(f);
 
     return 0;
-- 
2.50.1
Re: [PATCH v2 13/24] migration/postcopy: Send device states without copying buffer
Posted by Fabiano Rosas 1 week, 4 days ago
Peter Xu <peterx@redhat.com> writes:

> Put buffer can be async as long as the flush happens before the buffer will
> be recycled / reused.  Do it for postcopy package data.  Quick measurement
> shows a small VM the time to push / flush the package shrinks from 91us to
> 38us.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/savevm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 9d2109718a..d41e89228d 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1136,7 +1136,8 @@ int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len)
>      trace_qemu_savevm_send_packaged();
>      qemu_savevm_command_send(f, MIG_CMD_PACKAGED, 4, (uint8_t *)&tmp);
>  
> -    qemu_put_buffer(f, buf, len);
> +    /* We can use async put because the qemufile will be flushed right away */
> +    qemu_put_buffer_async(f, buf, len, false);
>      qemu_fflush(f);
>  
>      return 0;

Reviewed-by: Fabiano Rosas <farosas@suse.de>