[PATCH RFC 8/9] migration/ram: Remove workaround on ram yield during load

Peter Xu posted 9 patches 1 month ago
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, Hailiang Zhang <zhanghailiang@xfusion.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Li Zhijian <lizhijian@fujitsu.com>
[PATCH RFC 8/9] migration/ram: Remove workaround on ram yield during load
Posted by Peter Xu 1 month ago
This reverts e65cec5e5d97927d22b39167d3e8edeffc771788.

RAM load path had a hack in the past explicitly yield the thread to the
main coroutine when RAM load spinning in a tight loop.  Not needed now
because precopy RAM load now happens without the main thread.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/ram.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 7208bc114f..2d9a6d1095 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -4168,7 +4168,7 @@ static int parse_ramblocks(QEMUFile *f, ram_addr_t total_ram_bytes)
 static int ram_load_precopy(QEMUFile *f)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();
-    int flags = 0, ret = 0, invalid_flags = 0, i = 0;
+    int flags = 0, ret = 0, invalid_flags = 0;
 
     if (migrate_mapped_ram()) {
         invalid_flags |= (RAM_SAVE_FLAG_HOOK | RAM_SAVE_FLAG_MULTIFD_FLUSH |
@@ -4181,17 +4181,6 @@ static int ram_load_precopy(QEMUFile *f)
         void *host = NULL, *host_bak = NULL;
         uint8_t ch;
 
-        /*
-         * Yield periodically to let main loop run, but an iteration of
-         * the main loop is expensive, so do it each some iterations
-         */
-        if ((i & 32767) == 0 && qemu_in_coroutine()) {
-            aio_co_schedule(qemu_get_current_aio_context(),
-                            qemu_coroutine_self());
-            qemu_coroutine_yield();
-        }
-        i++;
-
         addr = qemu_get_be64(f);
         ret = qemu_file_get_error(f);
         if (ret) {
-- 
2.50.1
Re: [PATCH RFC 8/9] migration/ram: Remove workaround on ram yield during load
Posted by Fabiano Rosas 1 week, 3 days ago
Peter Xu <peterx@redhat.com> writes:

> This reverts e65cec5e5d97927d22b39167d3e8edeffc771788.
>
> RAM load path had a hack in the past explicitly yield the thread to the
> main coroutine when RAM load spinning in a tight loop.  Not needed now
> because precopy RAM load now happens without the main thread.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/ram.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 7208bc114f..2d9a6d1095 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -4168,7 +4168,7 @@ static int parse_ramblocks(QEMUFile *f, ram_addr_t total_ram_bytes)
>  static int ram_load_precopy(QEMUFile *f)
>  {
>      MigrationIncomingState *mis = migration_incoming_get_current();
> -    int flags = 0, ret = 0, invalid_flags = 0, i = 0;
> +    int flags = 0, ret = 0, invalid_flags = 0;
>  
>      if (migrate_mapped_ram()) {
>          invalid_flags |= (RAM_SAVE_FLAG_HOOK | RAM_SAVE_FLAG_MULTIFD_FLUSH |
> @@ -4181,17 +4181,6 @@ static int ram_load_precopy(QEMUFile *f)
>          void *host = NULL, *host_bak = NULL;
>          uint8_t ch;
>  
> -        /*
> -         * Yield periodically to let main loop run, but an iteration of
> -         * the main loop is expensive, so do it each some iterations
> -         */
> -        if ((i & 32767) == 0 && qemu_in_coroutine()) {
> -            aio_co_schedule(qemu_get_current_aio_context(),
> -                            qemu_coroutine_self());
> -            qemu_coroutine_yield();
> -        }
> -        i++;
> -
>          addr = qemu_get_be64(f);
>          ret = qemu_file_get_error(f);
>          if (ret) {

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