[PATCH RFC 7/9] migration/postcopy: Remove workaround on wait preempt channel

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 7/9] migration/postcopy: Remove workaround on wait preempt channel
Posted by Peter Xu 1 month ago
This reverts commit 7afbdada7effbc2b97281bfbce0c6df351a3cf88.

Now after switching to a thread in loadvm process, the main thread should
be able to accept() even if loading the package could cause a page fault in
userfaultfd path.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/savevm.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index ad606c5425..8018f7ad31 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2425,27 +2425,6 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis,
 
     QEMUFile *packf = qemu_file_new_input(QIO_CHANNEL(bioc));
 
-    /*
-     * Before loading the guest states, ensure that the preempt channel has
-     * been ready to use, as some of the states (e.g. via virtio_load) might
-     * trigger page faults that will be handled through the preempt channel.
-     * So yield to the main thread in the case that the channel create event
-     * hasn't been dispatched.
-     *
-     * TODO: if we can move migration loadvm out of main thread, then we
-     * won't block main thread from polling the accept() fds.  We can drop
-     * this as a whole when that is done.
-     */
-    do {
-        if (!migrate_postcopy_preempt() || !qemu_in_coroutine() ||
-            mis->postcopy_qemufile_dst) {
-            break;
-        }
-
-        aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self());
-        qemu_coroutine_yield();
-    } while (1);
-
     ret = qemu_loadvm_state_main(packf, mis, bql_held);
     trace_loadvm_handle_cmd_packaged_main(ret);
     qemu_fclose(packf);
-- 
2.50.1
Re: [PATCH RFC 7/9] migration/postcopy: Remove workaround on wait preempt channel
Posted by Fabiano Rosas 1 week, 3 days ago
Peter Xu <peterx@redhat.com> writes:

> This reverts commit 7afbdada7effbc2b97281bfbce0c6df351a3cf88.
>
> Now after switching to a thread in loadvm process, the main thread should
> be able to accept() even if loading the package could cause a page fault in
> userfaultfd path.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/savevm.c | 21 ---------------------
>  1 file changed, 21 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index ad606c5425..8018f7ad31 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2425,27 +2425,6 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis,
>  
>      QEMUFile *packf = qemu_file_new_input(QIO_CHANNEL(bioc));
>  
> -    /*
> -     * Before loading the guest states, ensure that the preempt channel has
> -     * been ready to use, as some of the states (e.g. via virtio_load) might
> -     * trigger page faults that will be handled through the preempt channel.
> -     * So yield to the main thread in the case that the channel create event
> -     * hasn't been dispatched.
> -     *
> -     * TODO: if we can move migration loadvm out of main thread, then we
> -     * won't block main thread from polling the accept() fds.  We can drop
> -     * this as a whole when that is done.
> -     */
> -    do {
> -        if (!migrate_postcopy_preempt() || !qemu_in_coroutine() ||
> -            mis->postcopy_qemufile_dst) {
> -            break;
> -        }
> -
> -        aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self());
> -        qemu_coroutine_yield();
> -    } while (1);
> -
>      ret = qemu_loadvm_state_main(packf, mis, bql_held);
>      trace_loadvm_handle_cmd_packaged_main(ret);
>      qemu_fclose(packf);

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