Allow to enable multifd and postcopy migration together
v8 cover Allow to enable multifd and postcopy migration together
From: Prasad Pandit <[email protected]>
Hello,
* This series (v8) splits earlier patch-2 which enabled multifd and postcopy options together into two separate patches. One modifies the channel discovery in migration_ioc_process_incoming() function, and second one enables the multifd and postcopy migration together.
It also adds the 'save_postcopy_prepare' savevm_state handler to enable different sections to take an action just before the Postcopy phase starts. Thank you Peter for these patches.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 152.66s 81 subtests passed
===
v7: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v7) adds 'MULTIFD_RECV_SYNC' migration command. It is used to notify the destination migration thread to synchronise with the Multifd threads. This allows Multifd ('mig/dst/recv_x') threads on the destination to receive all their data, before they are shutdown.
This series also updates the channel discovery function and qtests as suggested in the previous review comments.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 147.84s 81 subtests passed
===
v6: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v6) shuts down Multifd threads before starting Postcopy migration. It helps to avoid an issue of multifd pages arriving late at the destination during Postcopy phase and corrupting the vCPU state. It also reorders the qtest patches and does some refactoring changes as suggested in previous review.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 161.35s 73 subtests passed
===
v5: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v5) consolidates migration capabilities setting in one 'set_migration_capabilities()' function, thus simplifying test sources. It passes all migration tests.
===
66/66 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 143.66s 71 subtests passed
===
v4: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v4) adds more 'multifd+postcopy' qtests which test Precopy migration with 'postcopy-ram' attribute set. And run
Postcopy migrations with 'multifd' channels enabled.
===
$ ../qtest/migration-test --tap -k -r '/x86_64/migration/multifd+postcopy' | grep -i 'slow test' # slow test /x86_64/migration/multifd+postcopy/plain executed in 1.29 secs # slow test /x86_64/migration/multifd+postcopy/recovery/tls/psk executed in 2.48 secs # slow test /x86_64/migration/multifd+postcopy/preempt/plain executed in 1.49 secs # slow test /x86_64/migration/multifd+postcopy/preempt/recovery/tls/psk executed in 2.52 secs # slow test /x86_64/migration/multifd+postcopy/tcp/tls/psk/match executed in 3.62 secs # slow test /x86_64/migration/multifd+postcopy/tcp/plain/zstd executed in 1.34 secs # slow test /x86_64/migration/multifd+postcopy/tcp/plain/cancel executed in 2.24 secs ... 66/66 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 148.41s 71 subtests passed ===
v3: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* This series (v3) passes all existing 'tests/qtest/migration/*' tests and adds a new one to enable multifd channels with postcopy migration.
v2: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* This series (v2) further refactors the 'ram_save_target_page' function to make it independent of the multifd & postcopy change.
v1: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* This series removes magic value (4-bytes) introduced in the
previous series for the Postcopy channel.
v0: https://lore.kernel.org/qemu-devel/[email protected]/T/#u
* Currently Multifd and Postcopy migration can not be used together.
QEMU shows "Postcopy is not yet compatible with multifd" message.
When migrating guests with large (100's GB) RAM, Multifd threads help to accelerate migration, but inability to use it with the Postcopy mode delays guest start up on the destination side.
* This patch series allows to enable both Multifd and Postcopy migration together. Precopy and Multifd threads work during the initial guest (RAM) transfer. When migration moves to the Postcopy phase, Multifd threads are restrained and the Postcopy threads start to request pages from the source side.
* This series introduces magic value (4-bytes) to be sent on the Postcopy channel. It helps to differentiate channels and properly setup incoming connections on the destination side.
Thank you.
---
Peter Xu (2):
migration: Add save_postcopy_prepare() savevm handler migration/ram: Implement save_postcopy_prepare()
Prasad Pandit (5):
migration/multifd: move macros to multifd header
migration: Refactor channel discovery mechanism
migration: enable multifd and postcopy together tests/qtest/migration: consolidate set capabilities tests/qtest/migration: add postcopy tests with multifd
include/migration/register.h | 15 +++ migration/migration.c | 128 ++++++++++++---------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 12 +- migration/multifd.h | 5 + migration/options.c | 5 - migration/ram.c | 44 +++++++- migration/savevm.c | 33 ++++++ migration/savevm.h | 1 + tests/qtest/migration/compression-tests.c | 38 ++++++- tests/qtest/migration/cpr-tests.c | 6 +- tests/qtest/migration/file-tests.c | 58 +++++----- tests/qtest/migration/framework.c | 76 +++++++++---- tests/qtest/migration/framework.h | 9 +- tests/qtest/migration/misc-tests.c | 4 +- tests/qtest/migration/postcopy-tests.c | 35 +++++- tests/qtest/migration/precopy-tests.c | 48 +++++--- tests/qtest/migration/tls-tests.c | 70 +++++++++++- 18 files changed, 436 insertions(+), 154 deletions(-)
Signature · 1 line
2.48.1
PATCH v8 1/7 migration/multifd: move macros to multifd header
From: Prasad Pandit <[email protected]>
Move MULTIFD_ macros to the header file so that
they are accessible from other source files.
--- migration/multifd.c | 5 ----- migration/multifd.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
v7: no change
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/multifd.c +0 -5
@@ -36,11 +36,6 @@#include "io/channel-socket.h" #include "yank_functions.h" -/* Multiple fd's */ - -#define MULTIFD_MAGIC 0x11223344U -#define MULTIFD_VERSION 1 - typedef struct { uint32_t magic; uint32_t version;
migration/multifd.h +5 -0
@@ -49,6 +49,11 @@ bool multifd_queue_page(RAMBlock *block, ram_addr_t offset);bool multifd_recv (void );MultiFDRecvData *multifd_get_recv_data (void ); +/* Multiple fd's */ + +#define MULTIFD_MAGIC 0x11223344U +#define MULTIFD_VERSION 1 +/* Multifd Compression flags */ #define MULTIFD_FLAG_SYNC (1 << 0)
Signature · 1 line
2.48.1
PATCH v8 2/7 migration: Refactor channel discovery mechanism
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
The various logical migration channels don't have a standardized way of advertising themselves and their connections may be seen out of order by the migration destination. When a new connection arrives, the incoming migration currently make use of heuristics to determine which channel it belongs to.
The next few patches will need to change how the multifd and postcopy capabilities interact and that affects the channel discovery heuristic.
Refactor the channel discovery heuristic to make it less opaque and simplify the subsequent patches.
--- migration/migration.c | 124 +++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 55 deletions(-)
v8:
- Separate this patch out from earlier patch-2
v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/migration.c +69 -55
@@ -95,6 +95,9 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; +/* Migration channel types */ +enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +/* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */
@@ -985,28 +988,19 @@ void migration_fd_process_incoming(QEMUFile *f)migration_incoming_process (); } -/* -* Returns true when we want to start a new incoming migration process, -* false otherwise. -*/ -static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) { -/* Multifd doesn't start unless all channels are established */ -if (migrate_multifd ()) { -return migration_has_all_channels (); +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; } -/* Preempt channel only starts when the main channel is created */ -if (migrate_postcopy_preempt ()) { -return main_channel; +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; } -/* -* For all the rest types of migration, we should only reach here when -* it's the main channel that's being created, and we should always -* proceed with this channel. -*/ -assert (main_channel); +/* main and all multifd channels are established */ return true; }
@@ -1015,59 +1009,84 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;QEMUFile *f; -bool default_channel = true; +uint8_t channel;uint32_t channel_magic =0 ;int ret =0 ; -if (migrate_multifd () && !migrate_mapped_ram () && - !migrate_postcopy_ram () && -qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { -/* -* With multiple channels, it is possible that we receive channels -* out of order on destination side, causing incorrect mapping of -* source channels on destination side. Check channel MAGIC to -* decide type of channel. Please note this is best effort, postcopy -* preempt channel does not send any magic number so avoid it for -* postcopy live migration. Also tls live migration already does -* tls handshake while initializing main channel so with tls this -* issue is not possible. -*/ - ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); +if (!migration_has_main_and_multifd_channels ()) { +if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { +/* +* With multiple channels, it is possible that we receive channels +* out of order on destination side, causing incorrect mapping of +* source channels on destination side. Check channel MAGIC to +* decide type of channel. Please note this is best effort, +* postcopy preempt channel does not send any magic number so +* avoid it for postcopy live migration. Also tls live migration +* already does tls handshake while initializing main channel so +* with tls this issue is not possible. +*/ + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ; + } -if (ret !=0 ) { + channel_magic =be32_to_cpu (channel_magic); +if (channel_magic ==QEMU_VM_FILE_MAGIC ) { + channel =CH_MAIN ; + }else if (channel_magic ==MULTIFD_MAGIC ) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file && + mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) { +/* reconnect main channel for postcopy recovery */ + channel =CH_MAIN ; + }else { +error_setg (errp,"unknown channel magic: %u" , channel_magic); +return ; + } + }else if (mis->from_src_file &&migrate_multifd ()) { +/* +* Non-peekable channels like tls/file are processed as +* multifd channels when multifd is enabled. +*/ + channel =CH_MULTIFD ; + }else if (!mis->from_src_file) { + channel =CH_MAIN ; + }else { +error_setg (errp,"non-peekable channel used without multifd" );return ; } - - default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); + }else if (mis->from_src_file) { + channel =CH_POSTCOPY ; }else { - default_channel = !mis->from_src_file; + channel =CH_MAIN ; }if (multifd_recv_setup (errp) !=0 ) {return ; } -if (default_channel) { +if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f); - }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {multifd_recv_new_channel (ioc, &local_err); - }else { -assert (migrate_postcopy_preempt ()); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); }if (local_err) {error_propagate (errp, local_err);return ; } + }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return ; } -if (migration_should_start_incoming (default_channel)) { +if (migration_has_main_and_multifd_channels ()) {/* If it's a recovery, we're done */ if (postcopy_try_recover ()) {return ;
@@ -1084,20 +1103,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)*/ bool migration_has_all_channels (void ) { +if (!migration_has_main_and_multifd_channels ()) { +return false; + } +MigrationIncomingState *mis =migration_incoming_get_current (); - -if (!mis->from_src_file) { +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) {return false; } -if (migrate_multifd ()) { -return multifd_recv_all_channels_created (); - } - -if (migrate_postcopy_preempt ()) { -return mis->postcopy_qemufile_dst !=NULL ; - } -return true; }
Signature · 1 line
2.48.1
Re: [PATCH v8 2/7] migration: Refactor channel discovery mechanism
Quoted 139 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
The various logical migration channels don't have a standardized way of advertising themselves and their connections may be seen out of order by the migration destination. When a new connection arrives, the incoming migration currently make use of heuristics to determine which channel it belongs to.
The next few patches will need to change how the multifd and postcopy capabilities interact and that affects the channel discovery heuristic.
Refactor the channel discovery heuristic to make it less opaque and simplify the subsequent patches.
Signed-off-by Prasad Pandit <[email protected]>--- migration/migration.c | 124 +++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 55 deletions(-)v8:
- Separate this patch out from earlier patch-2v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#tmigration/migration.c +47
-34@@ -95,6 +95,9 @@ enum mig_rp_message_type { MIG_RP_MSG_MAX }; +/* Migration channel types */ +enum {CH_MAIN ,CH_MULTIFD ,CH_POSTCOPY }; +/* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */ @@ -985,28 +988,19 @@ void migration_fd_process_incoming(QEMUFile *f)migration_incoming_process (); } -/* -* Returns true when we want to start a new incoming migration process, -* false otherwise. -*/ -static bool migration_should_start_incoming (bool main_channel) +static bool migration_has_main_and_multifd_channels (void ) { -/* Multifd doesn't start unless all channels are established */ -if (migrate_multifd ()) { -return migration_has_all_channels (); +MigrationIncomingState *mis =migration_incoming_get_current (); +if (!mis->from_src_file) { +/* main channel not established */ +return false; } -/* Preempt channel only starts when the main channel is created */ -if (migrate_postcopy_preempt ()) { -return main_channel; +if (migrate_multifd () && !multifd_recv_all_channels_created ()) { +return false; } -/* -* For all the rest types of migration, we should only reach here when -* it's the main channel that's being created, and we should always -* proceed with this channel. -*/ -assert (main_channel); +/* main and all multifd channels are established */ return true; }@@ -1015,59 +1009,84 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)MigrationIncomingState *mis =migration_incoming_get_current ();Error *local_err =NULL ;QEMUFile *f; -bool default_channel = true; +uint8_t channel;uint32_t channel_magic =0 ;int ret =0 ; -if (migrate_multifd () && !migrate_mapped_ram () && - !migrate_postcopy_ram () && -qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { -/* -* With multiple channels, it is possible that we receive channels -* out of order on destination side, causing incorrect mapping of -* source channels on destination side. Check channel MAGIC to -* decide type of channel. Please note this is best effort, postcopy -* preempt channel does not send any magic number so avoid it for -* postcopy live migration. Also tls live migration already does -* tls handshake while initializing main channel so with tls this -* issue is not possible. -*/ - ret =migration_channel_read_peek (ioc, (void *)&channel_magic, -sizeof (channel_magic), errp); +if (!migration_has_main_and_multifd_channels ()) { +if (qio_channel_has_feature (ioc,QIO_CHANNEL_FEATURE_READ_MSG_PEEK )) { +/* +* With multiple channels, it is possible that we receive channels +* out of order on destination side, causing incorrect mapping of +* source channels on destination side. Check channel MAGIC to +* decide type of channel. Please note this is best effort, +* postcopy preempt channel does not send any magic number so +* avoid it for postcopy live migration. Also tls live migration +* already does tls handshake while initializing main channel so +* with tls this issue is not possible. +*/ + ret =migration_channel_read_peek (ioc, (void *)&channel_magic, +sizeof (channel_magic), errp); +if (ret !=0 ) { +return ; + } -if (ret !=0 ) { + channel_magic =be32_to_cpu (channel_magic); +if (channel_magic ==QEMU_VM_FILE_MAGIC ) { + channel =CH_MAIN ; + }else if (channel_magic ==MULTIFD_MAGIC ) { + channel =CH_MULTIFD ; + }else if (!mis->from_src_file && + mis->state ==MIGRATION_STATUS_POSTCOPY_PAUSED ) { +/* reconnect main channel for postcopy recovery */ + channel =CH_MAIN ; + }else { +error_setg (errp,"unknown channel magic: %u" , channel_magic); +return ; + } + }else if (mis->from_src_file &&migrate_multifd ()) { +/* +* Non-peekable channels like tls/file are processed as +* multifd channels when multifd is enabled. +*/
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1059
Quoted 10 lines
migration/migration.c +6
-2+ channel =CH_MULTIFD ; + }else if (!mis->from_src_file) { + channel =CH_MAIN ; + }else { +error_setg (errp,"non-peekable channel used without multifd" );return ; } - - default_channel = (channel_magic ==cpu_to_be32 (QEMU_VM_FILE_MAGIC )); + }else if (mis->from_src_file) {
This is redundant.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1062
Quoted 4 lines
migration/migration.c +2
-1+ channel =CH_POSTCOPY ; }else { - default_channel = !mis->from_src_file; + channel =CH_MAIN ;
And this is impossible.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1071
Quoted 10 lines
migration/migration.c +1
-1}if (multifd_recv_setup (errp) !=0 ) {return ; } -if (default_channel) { +if (channel ==CH_MAIN ) { f =qemu_file_new_input (ioc);migration_incoming_setup (f);
We should probably expand migration_incoming_setup() to make it clear that mis->from_src_file is set at this point. And assert(!mis->from_src_file). I can send a patch on top later.
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1074
Quoted 5 lines
migration/migration.c +1
-2- }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {
This should be an assert.
Quoted 10 lines
migration/migration.c +0
-4multifd_recv_new_channel (ioc, &local_err); - }else { -assert (migrate_postcopy_preempt ()); - f =qemu_file_new_input (ioc); -postcopy_preempt_new_channel (mis, f); }if (local_err) {error_propagate (errp, local_err);return ; }
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1089
Quoted 10 lines
migration/migration.c +7
-1+ }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return ; } -if (migration_should_start_incoming (default_channel)) { +if (migration_has_main_and_multifd_channels ()) {
I think there's a bug here. Excluding multifd from the picture, if only the main channel needs to be setup, then it's possible to start postcopy recovery twice, once when the main channel appears and another time when the preempt channel appears.
The previous code worked differently because it did:
if (migrate_postcopy_preempt()) {
return main_channel;which would return false when preempt arrived after main.
We could use migration_has_all_channels() instead, that would look more logically correct, but it would also change the current behavior that postcopy recovery can start before the preempt channel is in place. I'm not even sure if that's actually part of the design of the feature.
Quoted 28 lines
migration/migration.c +5
-10/* If it's a recovery, we're done */ if (postcopy_try_recover ()) {return ;@@ -1084,20 +1103,15 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)*/ bool migration_has_all_channels (void ) { +if (!migration_has_main_and_multifd_channels ()) { +return false; + } +MigrationIncomingState *mis =migration_incoming_get_current (); - -if (!mis->from_src_file) { +if (migrate_postcopy_preempt () && !mis->postcopy_qemufile_dst) {return false; } -if (migrate_multifd ()) { -return multifd_recv_all_channels_created (); - } - -if (migrate_postcopy_preempt ()) { -return mis->postcopy_qemufile_dst !=NULL ; - } -return true; }
Re: [PATCH v8 2/7] migration: Refactor channel discovery mechanism
Hello Fabiano,
Quoted 2 lines · Fabiano Rosas
Quoted 1 line
+ } else if (
mis->from_src_file) {This is redundant.
* This was to ensure (double check) that when the Postcopy connection comes in, the main channel is established. Also a couple of versions back migration qtest was failing without this check. Nonetheless, qtests do work now without this check. I'll remove it if we must.
Quoted 6 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1062
Quoted 4 lines
migration/migration.c +2
-1+ channel =CH_POSTCOPY ; }else { - default_channel = !mis->from_src_file; + channel =CH_MAIN ;And this is impossible.
-> https://lore.kernel.org/qemu-devel/[email protected]/T/#m18b6bf30e877f9eafaa67bba6a209b47782f6eac
* Yes, but a couple of revisions back you suggested adding it saying CH_MAIN assignment at the top was doing some heavy lifting and it's more clear this way.
Quoted 3 lines
We should probably expand
migration_incoming_setup()to make it clear thatmis->from_src_fileis set at this point. Andassert(!mis->from_src_file). I can send a patch on top later.
* migration_incoming_setup uses the QEMUFile object only when mis->from_src_file is not set. I'm wondering if we really need an assert(!mis->from_src_file) check? Because it'll reach here only when channel == CH_MAIN and channel is set to CH_MAIN only when mis->from_src_file is NULL.
Quoted 7 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1074
Quoted 5 lines
migration/migration.c +1
-2- }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {This should be an assert.
Same, 'channel' is set to CH_MULTIFD, only when migrate_multifd() is enabled. Do we need another assert(migrate_multifd()) check?
Quoted 8 lines
Quoted 8 lines
migration/migration.c +6
-0+ }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return ; }
Quoted 7 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1089
Quoted 2 lines
migration/migration.c +1
-1-if (migration_should_start_incoming (default_channel)) { +if (migration_has_main_and_multifd_channels ()) {I think there's a bug here. Excluding multifd from the picture, if only the main channel needs to be setup, then it's possible to start postcopy recovery twice, once when the main channel appears and another time when the preempt channel appears.
* When the preempt channel appears 'channel' is set to CH_POSTCOPY, so it shall 'return' before reaching here, right?
===
} else if (!mis->from_src_file &&
mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) {
/* reconnect main channel for postcopy recovery */
channel = CH_MAIN;
} else {===
* When 'main' channel connection arrives for postcopy recovery, 'channel' shall be set to CH_MAIN.
Quoted 6 lines
The previous code worked differently because it did:
if (migrate_postcopy_preempt()) { return main_channel;which would return false when preempt arrived after main.
* Yes.
Quoted 4 lines
We could use
migration_has_all_channels()instead, that would look more logically correct, but it would also change the current behavior that postcopy recovery can start before the preempt channel is in place. I'm not even sure if that's actually part of the design of the feature.
* Not sure if we need this.
Thank you.
---
- Prasad
Re: [PATCH v8 2/7] migration: Refactor channel discovery mechanism
Quoted 11 lines · Prasad Pandit
Hello Fabiano,
Quoted 2 lines · Fabiano Rosas
Quoted 1 line
+ } else if (
mis->from_src_file) {This is redundant.
* This was to ensure (double check) that when the Postcopy connection comes in, the main channel is established. Also a couple of versions back migration qtest was failing without this check. Nonetheless, qtests do work now without this check. I'll remove it if we must.
Yes, there's no point. if we already have main and multifd channels, what's left must be postcopy.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
migration/migration.c +2
-1+ channel =CH_POSTCOPY ; }else { - default_channel = !mis->from_src_file; + channel =CH_MAIN ;
Quoted 8 lines
Quoted 1 line
And this is impossible.
-> https://lore.kernel.org/qemu-devel/[email protected]/T/#m18b6bf30e877f9eafaa67bba6a209b47782f6eac* Yes, but a couple of revisions back you suggested adding it saying
CH_MAINassignment at the top was doing some heavy lifting and it's more clear this way.
Well, but don't add it blindly if it doesn't make sense. The point was to not end the conditional at 'else if' because that makes the reader have to go look around the code to see what was already assigned. Here we want just a plain:
else {
channel = CH_POSTCOPY;
}Quoted 11 lines
Quoted 3 lines
We should probably expand
migration_incoming_setup()to make it clear thatmis->from_src_fileis set at this point. Andassert(!mis->from_src_file). I can send a patch on top later.*
migration_incoming_setupuses the QEMUFile object only whenmis->from_src_fileis not set. I'm wondering if we really need anassert(!mis->from_src_file)check? Because it'll reach here only when channel ==CH_MAINand channel is set toCH_MAINonly whenmis->from_src_fileis NULL.
Given the:
if (!mis->from_src_file) {
I think someone (back in 2017) thought it was possible to reach there with from_src_file already set. I don't know whether that applied to this path. In any case, for this function I believe the correct is assert because we shouldn't have two channels arriving as main.
Quoted 11 lines
Quoted 7 lines
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 1074
Quoted 5 lines
migration/migration.c +1
-2- }else { + }else if (channel ==CH_MULTIFD ) {/* Multiple connections */ -assert (migration_needs_multiple_sockets ());if (migrate_multifd ()) {This should be an assert.
Same, 'channel' is set to
CH_MULTIFD, only whenmigrate_multifd()is enabled. Do we need another assert(migrate_multifd()) check?
Maybe not, but we definitely cannot just ignore if it happens and we also should not have an empty check that is always known to be true. So either assert or remove the if entirely.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
migration/migration.c +7
-1+ }else if (channel ==CH_POSTCOPY ) { +assert (migrate_postcopy_preempt ()); +assert (!mis->postcopy_qemufile_dst); + f =qemu_file_new_input (ioc); +postcopy_preempt_new_channel (mis, f); +return ; } -if (migration_should_start_incoming (default_channel)) { +if (migration_has_main_and_multifd_channels ()) {
Quoted 8 lines
Quoted 4 lines
I think there's a bug here. Excluding multifd from the picture, if only the main channel needs to be setup, then it's possible to start postcopy recovery twice, once when the main channel appears and another time when the preempt channel appears.
* When the preempt channel appears 'channel' is set to
CH_POSTCOPY, so it shall 'return' before reaching here, right?
You're right, I missed the return statement.
Quoted 29 lines
===
} else if (!mis->from_src_file && mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { /* reconnect main channel for postcopy recovery */ channel = CH_MAIN; } else {===
* When 'main' channel connection arrives for postcopy recovery, 'channel' shall be set toCH_MAIN.Quoted 6 lines
The previous code worked differently because it did:
if (migrate_postcopy_preempt()) { return main_channel;which would return false when preempt arrived after main.
* Yes.
Quoted 4 lines
We could use
migration_has_all_channels()instead, that would look more logically correct, but it would also change the current behavior that postcopy recovery can start before the preempt channel is in place. I'm not even sure if that's actually part of the design of the feature.* Not sure if we need this.
Thank you.
---
- Prasad
Re: [PATCH v8 2/7] migration: Refactor channel discovery mechanism
Quoted 2 lines · Fabiano Rosas
Yes, there's no point. if we already have main and multifd channels, what's left must be postcopy.
* Okay.
Quoted 1 line
Well, but don't add it blindly if it doesn't make sense.
* Hmmn, okay. When I say/do things that seem reasonable to me, I'm told - it's much easier to just do things than arguing over them. When I do something because it's a minor change, I'm admonished with this. Life is tricky. :)
Quoted 7 lines
The point was to not end the conditional at 'else if' because that makes the reader have to go look around the code to see what was already assigned. Here we want just a plain:
else { channel = CH_POSTCOPY; }
* Okay.
Quoted 6 lines
Quoted 5 lines
*
migration_incoming_setupuses the QEMUFile object only whenmis->from_src_fileis not set. I'm wondering if we really need anassert(!mis->from_src_file)check? Because it'll reach here only when channel ==CH_MAINand channel is set toCH_MAINonly whenmis->from_src_fileis NULL.
Quoted 7 lines
Given the:
if (!mis->from_src_file) {I think someone (back in 2017) thought it was possible to reach there with
from_src_filealready set. I don't know whether that applied to this path. In any case, for this function I believe the correct is assert because we shouldn't have two channels arriving as main.
* Okay.
* If we add assert(!mis->from_src_file), then the if (!mis->from_src_file) check in migration_incoming_setup() is not needed then.
Quoted 3 lines
Maybe not, but we definitely cannot just ignore if it happens and we also should not have an empty check that is always known to be true. So either assert or remove the if entirely.
* Okay. I'll add an assert(migrate_multifd()). That should be consistent with the other assert(!mis->from_src_file), assert(migrate_postcopy_preempt()) and assert(!mis->postcopy_qemufile_dst) calls in there.
Thank you.
---
- Prasad
PATCH v8 3/7 migration: enable multifd and postcopy together
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Enable Multifd and Postcopy migration together. The migration_ioc_process_incoming() routine checks magic value sent on each channel and helps to properly setup multifd and postcopy channels.
The Precopy and Multifd threads work during the initial guest RAM transfer. When migration moves to the Postcopy phase, the multifd threads cease to send data on multifd channels and Postcopy threads on the destination request/pull data from the source side.
--- migration/multifd-nocomp.c | 3 ++- migration/multifd.c | 7 +++++++ migration/options.c | 5 ----- migration/ram.c | 7 +++---- 4 files changed, 12 insertions(+), 10 deletions(-)
v8:
- Separate this patch out from earlier patch-2.
v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/multifd-nocomp.c +2 -1
@@ -17,6 +17,7 @@#include "migration-stats.h" #include "multifd.h" #include "options.h" +#include "migration.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h"
@@ -399,7 +400,7 @@ int multifd_ram_flush_and_sync(QEMUFile *f)MultiFDSyncReq req;int ret; -if (!migrate_multifd ()) { +if (!migrate_multifd () ||migration_in_postcopy ()) {return 0 ; }
migration/multifd.c +7 -0
@@ -1379,6 +1379,13 @@ static void *multifd_recv_thread(void *opaque) }if (has_data) { +/* +* multifd thread should not be active and receive data +* when migration is in the Postcopy phase. Two threads +* writing the same memory area could easily corrupt +* the guest state. +*/ +assert (!migration_in_postcopy ());if (is_device_state) {assert (use_packets); ret =multifd_device_state_recv (p, &local_err);
migration/options.c +0 -5
@@ -491,11 +491,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)error_setg (errp,"Postcopy is not compatible with ignore-shared" );return false; } - -if (new_caps[MIGRATION_CAPABILITY_MULTIFD ]) { -error_setg (errp,"Postcopy is not yet compatible with multifd" ); -return false; - } }if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT ]) {
migration/ram.c +3 -4
@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY ].pss_channel;int ret =multifd_ram_flush_and_sync (f);if (ret <0 ) {
@@ -1976,9 +1976,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) } } -if (migrate_multifd ()) { -RAMBlock *block = pss->block; -return ram_save_multifd_page (block, offset); +if (migrate_multifd () && !migration_in_postcopy ()) { +return ram_save_multifd_page (pss->block, offset); }return ram_save_page (rs, pss);
Signature · 1 line
2.48.1
Re: [PATCH v8 3/7] migration: enable multifd and postcopy together
Quoted 89 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Enable Multifd and Postcopy migration together. The
migration_ioc_process_incoming()routine checks magic value sent on each channel and helps to properly setup multifd and postcopy channels.The Precopy and Multifd threads work during the initial guest RAM transfer. When migration moves to the Postcopy phase, the multifd threads cease to send data on multifd channels and Postcopy threads on the destination request/pull data from the source side.
Signed-off-by Prasad Pandit <[email protected]>--- migration/multifd-nocomp.c | 3 ++- migration/multifd.c | 7 +++++++ migration/options.c | 5 ----- migration/ram.c | 7 +++---- 4 files changed, 12 insertions(+), 10 deletions(-)v8:
- Separate this patch out from earlier patch-2.v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#tmigration/multifd-nocomp.c +2
-1@@ -17,6 +17,7 @@#include "migration-stats.h" #include "multifd.h" #include "options.h" +#include "migration.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -399,7 +400,7 @@ int multifd_ram_flush_and_sync(QEMUFile *f)MultiFDSyncReq req;int ret; -if (!migrate_multifd ()) { +if (!migrate_multifd () ||migration_in_postcopy ()) {return 0 ; }migration/multifd.c +7
-0@@ -1379,6 +1379,13 @@ static void *multifd_recv_thread(void *opaque) }if (has_data) { +/* +* multifd thread should not be active and receive data +* when migration is in the Postcopy phase. Two threads +* writing the same memory area could easily corrupt +* the guest state. +*/ +assert (!migration_in_postcopy ());if (is_device_state) {assert (use_packets); ret =multifd_device_state_recv (p, &local_err);migration/options.c +0
-5@@ -491,11 +491,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)error_setg (errp,"Postcopy is not compatible with ignore-shared" );return false; } - -if (new_caps[MIGRATION_CAPABILITY_MULTIFD ]) { -error_setg (errp,"Postcopy is not yet compatible with multifd" ); -return false; - } }if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT ]) {migration/ram.c +0
-0
migration/ram.c static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) · line 1300
Quoted 5 lines
migration/ram.c +1
-1@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {
I'd rather not put this check here. multifd_ram_flush_and_sync() will already return 0 if in postcopy.
Quoted 15 lines
migration/ram.c +2
-3QEMUFile *f = rs->pss[RAM_CHANNEL_PRECOPY ].pss_channel;int ret =multifd_ram_flush_and_sync (f);if (ret <0 ) {@@ -1976,9 +1976,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss) } } -if (migrate_multifd ()) { -RAMBlock *block = pss->block; -return ram_save_multifd_page (block, offset); +if (migrate_multifd () && !migration_in_postcopy ()) { +return ram_save_multifd_page (pss->block, offset); }return ram_save_page (rs, pss);
Re: [PATCH v8 3/7] migration: enable multifd and postcopy together
Quoted 11 lines · Fabiano Rosas
migration/ram.c static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) · line 1300
Quoted 8 lines
migration/ram.c +1
-1@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {I'd rather not put this check here.
multifd_ram_flush_and_sync()will already return 0 if in postcopy.
* IIRC, without it migration did not finish or was crashing. I don't recall if it was on Fedora or RHEL systems.
Thank you.
---
- Prasad
Re: [PATCH v8 3/7] migration: enable multifd and postcopy together
Quoted 13 lines · Prasad Pandit
Quoted 11 lines · Fabiano Rosas
migration/ram.c static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) · line 1300
Quoted 8 lines
migration/ram.c +1
-1@@ -1297,7 +1297,7 @@ static int find_dirty_block(RAMState *rs, PageSearchStatus *pss) pss->page =0 ; pss->block =QLIST_NEXT_RCU (pss->block, next);if (!pss->block) { -if (multifd_ram_sync_per_round ()) { +if (multifd_ram_sync_per_round () && !migration_in_postcopy ()) {I'd rather not put this check here.
multifd_ram_flush_and_sync()will already return 0 if in postcopy.
Quoted 3 lines
* IIRC, without it migration did not finish or was crashing. I don't recall if it was on Fedora or RHEL systems.
Maybe you hit the issue I reported? Let's not duplicate the in_postcopy check unless it makes logical sense. If it crashes, we must figure out why.
Quoted 3 lines
Thank you.
---
- Prasad
PATCH v8 4/7 tests/qtest/migration: consolidate set capabilities
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Migration capabilities are set in multiple '.start_hook' functions for various tests. Instead, consolidate setting capabilities in 'migrate_start_set_capabilities()' function which is called from the 'migrate_start()' function. While simplifying the capabilities setting, it helps to declutter the qtest sources.
--- tests/qtest/migration/compression-tests.c | 22 +++++-- tests/qtest/migration/cpr-tests.c | 6 +- tests/qtest/migration/file-tests.c | 58 ++++++++--------- tests/qtest/migration/framework.c | 76 ++++++++++++++++------- tests/qtest/migration/framework.h | 9 ++- tests/qtest/migration/misc-tests.c | 4 +- tests/qtest/migration/postcopy-tests.c | 8 ++- tests/qtest/migration/precopy-tests.c | 29 +++++---- tests/qtest/migration/tls-tests.c | 23 ++++++- 9 files changed, 151 insertions(+), 84 deletions(-)
v7: no change
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
tests/qtest/migration/compression-tests.c +18 -4
@@ -35,6 +35,9 @@ static void test_multifd_tcp_zstd(void) {MigrateCommon args = { .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, };test_precopy_common (&args);
@@ -56,6 +59,9 @@ static void test_multifd_tcp_qatzip(void) {MigrateCommon args = { .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_qatzip, };test_precopy_common (&args);
@@ -74,6 +80,9 @@ static void test_multifd_tcp_qpl(void) {MigrateCommon args = { .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_qpl, };test_precopy_common (&args);
@@ -92,6 +101,9 @@ static void test_multifd_tcp_uadk(void) {MigrateCommon args = { .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_uadk, };test_precopy_common (&args);
@@ -103,10 +115,6 @@ migrate_hook_start_xbzrle(QTestState *from, QTestState *to) {migrate_set_parameter_int (from,"xbzrle-cache-size" ,33554432 ); - -migrate_set_capability (from,"xbzrle" , true); -migrate_set_capability (to,"xbzrle" , true); -return NULL ; }
@@ -118,6 +126,9 @@ static void test_precopy_unix_xbzrle(void) .listen_uri = uri, .start_hook = migrate_hook_start_xbzrle, .iterations = 2, + .start = { + .caps[MIGRATION_CAPABILITY_XBZRLE] = true, + },/* * XBZRLE needs pages to be modified when doing the 2nd+ round * iteration to have real data pushed to the stream.
@@ -146,6 +157,9 @@ static void test_multifd_tcp_zlib(void) {MigrateCommon args = { .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, .start_hook = migrate_hook_start_precopy_tcp_multifd_zlib, };test_precopy_common (&args);
tests/qtest/migration/cpr-tests.c +3 -3
@@ -24,9 +24,6 @@ static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *to)migrate_set_parameter_str (from,"mode" ,"cpr-reboot" );migrate_set_parameter_str (to,"mode" ,"cpr-reboot" ); -migrate_set_capability (from,"x-ignore-shared" , true); -migrate_set_capability (to,"x-ignore-shared" , true); -return NULL ; }
@@ -39,6 +36,9 @@ static void test_mode_reboot(void) .connect_uri = uri, .listen_uri = "defer", .start_hook = migrate_hook_start_mode_reboot, + .start = { + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true, + }, };test_file_common (&args, true);
tests/qtest/migration/file-tests.c +26 -32
129 lines not on this page · raw message
tests/qtest/migration/framework.c +52 -24
116 lines not on this page · raw message
tests/qtest/migration/framework.h +8 -1
@@ -12,6 +12,7 @@#define TEST_FRAMEWORK_H #include "libqtest.h" +#include <qapi/qapi-types-migration.h> #define FILE_TEST_FILENAME "migfile"#define FILE_TEST_OFFSET 0x1000
@@ -120,6 +121,13 @@ typedef struct {/* Do not connect to target monitor and qtest sockets in qtest_init */ bool defer_target_connect; + +/* +* Migration capabilities to be set in both source and +* destination. For unilateral capabilities, use +* migration_set_capabilities(). +*/ +bool caps[MIGRATION_CAPABILITY__MAX ]; } MigrateStart; typedef enum PostcopyRecoveryFailStage {
@@ -207,7 +215,6 @@ typedef struct {/* Postcopy specific fields */ void *postcopy_data; -bool postcopy_preempt;PostcopyRecoveryFailStage postcopy_recovery_fail_stage; } MigrateCommon;
tests/qtest/migration/misc-tests.c +1 -3
@@ -98,6 +98,7 @@ static void test_ignore_shared(void)QTestState *from, *to;MigrateStart args = { .use_shmem = true, + .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED ] = true, };if (migrate_start (&from, &to, uri, &args)) {
@@ -107,9 +108,6 @@ static void test_ignore_shared(void)migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from); -migrate_set_capability (from,"x-ignore-shared" , true); -migrate_set_capability (to,"x-ignore-shared" , true); -/* Wait for the first serial output from the source */ wait_for_serial ("src_serial" );
tests/qtest/migration/postcopy-tests.c +6 -2
@@ -39,7 +39,9 @@ static void test_postcopy_suspend(void)static void test_postcopy_preempt (void ) {MigrateCommon args = { - .postcopy_preempt = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_common (&args);
@@ -73,7 +75,9 @@ static void test_postcopy_recovery_fail_reconnect(void)static void test_postcopy_preempt_recovery (void ) {MigrateCommon args = { - .postcopy_preempt = true, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_recovery_common (&args);
tests/qtest/migration/precopy-tests.c +16 -13
@@ -108,23 +108,14 @@ static void test_precopy_tcp_plain(void)test_precopy_common (&args); } -static void *migrate_hook_start_switchover_ack (QTestState *from,QTestState *to) -{ - -migrate_set_capability (from,"return-path" , true); -migrate_set_capability (to,"return-path" , true); - -migrate_set_capability (from,"switchover-ack" , true); -migrate_set_capability (to,"switchover-ack" , true); - -return NULL ; -} -static void test_precopy_tcp_switchover_ack (void ) {MigrateCommon args = { .listen_uri ="tcp:127.0.0.1:0" , - .start_hook = migrate_hook_start_switchover_ack, + .start = { + .caps[MIGRATION_CAPABILITY_RETURN_PATH ] = true, + .caps[MIGRATION_CAPABILITY_SWITCHOVER_ACK ] = true, + },/* * Source VM must be running in order to consider the switchover ACK * when deciding to do switchover or not.
@@ -393,6 +384,9 @@ static void test_multifd_tcp_uri_none(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -408,6 +402,9 @@ static void test_multifd_tcp_zero_page_legacy(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_zero_page_legacy, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -423,6 +420,9 @@ static void test_multifd_tcp_no_zero_page(void)MigrateCommon args = { .listen_uri ="defer" , .start_hook = migrate_hook_start_precopy_tcp_multifd_no_zero_page, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + },/* * Multifd is more complicated than most of the features, it * directly takes guest page buffers when sending, make sure
@@ -439,6 +439,9 @@ static void test_multifd_tcp_channels_none(void) .listen_uri = "defer", .start_hook = migrate_hook_start_precopy_tcp_multifd, .live = true, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, .connect_channels = ("[ { 'channel-type': 'main'," " 'addr': { 'transport': 'socket'," " 'type': 'inet',"
tests/qtest/migration/tls-tests.c +21 -2
@@ -375,9 +375,11 @@ static void test_postcopy_tls_psk(void)static void test_postcopy_preempt_tls_psk (void ) {MigrateCommon args = { - .postcopy_preempt = true, .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_common (&args);
@@ -397,9 +399,11 @@ static void test_postcopy_recovery_tls_psk(void)static void test_postcopy_preempt_all (void ) {MigrateCommon args = { - .postcopy_preempt = true, .start_hook = migrate_hook_start_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .start = { + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, };test_postcopy_recovery_common (&args);
@@ -631,6 +635,9 @@ static void test_multifd_tcp_tls_psk_match(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tcp_tls_psk_match, .end_hook = migrate_hook_end_tls_psk, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -640,6 +647,7 @@ static void test_multifd_tcp_tls_psk_mismatch(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tcp_tls_psk_mismatch,
@@ -656,6 +664,9 @@ static void test_multifd_tcp_tls_x509_default_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_default_host, .end_hook = migrate_hook_end_tls_x509, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -666,6 +677,9 @@ static void test_multifd_tcp_tls_x509_override_host(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_override_host, .end_hook = migrate_hook_end_tls_x509, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -688,6 +702,7 @@ static void test_multifd_tcp_tls_x509_mismatch_host(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tls_x509_mismatch_host,
@@ -703,6 +718,9 @@ static void test_multifd_tcp_tls_x509_allow_anon_client(void) .listen_uri = "defer", .start_hook = migrate_hook_start_multifd_tls_x509_allow_anon_client, .end_hook = migrate_hook_end_tls_x509, + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD] = true, + }, };test_precopy_common (&args); }
@@ -712,6 +730,7 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void)MigrateCommon args = { .start = { .hide_stderr = true, + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, }, .listen_uri ="defer" , .start_hook = migrate_hook_start_multifd_tls_x509_reject_anon_client,
Signature · 1 line
2.48.1
PATCH v8 5/7 tests/qtest/migration: add postcopy tests with multifd
In reply to Prasad PanditFrom: Prasad Pandit <[email protected]>
Add new qtests to run postcopy migration with multifd channels enabled.
--- tests/qtest/migration/compression-tests.c | 16 ++++++++ tests/qtest/migration/postcopy-tests.c | 27 +++++++++++++ tests/qtest/migration/precopy-tests.c | 19 +++++++++ tests/qtest/migration/tls-tests.c | 47 +++++++++++++++++++++++ 4 files changed, 109 insertions(+)
v8:
- Set missing 'postcopy-ram' and 'multifd' capabilities for couple tests.
v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
tests/qtest/migration/compression-tests.c +16 -0
@@ -42,6 +42,20 @@ static void test_multifd_tcp_zstd(void) };test_precopy_common (&args); } + +static void test_multifd_postcopy_tcp_zstd (void ) +{ +MigrateCommon args = { + .listen_uri ="defer" , + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] = true, + }, + .start_hook = migrate_hook_start_precopy_tcp_multifd_zstd, + }; + +test_precopy_common (&args); +}#endif /* CONFIG_ZSTD */ #ifdef CONFIG_QATZIP
@@ -184,6 +198,8 @@ void migration_test_add_compression(MigrationTestEnv *env)#ifdef CONFIG_ZSTD migration_test_add ("/migration/multifd/tcp/plain/zstd" , test_multifd_tcp_zstd); +migration_test_add ("/migration/multifd+postcopy/tcp/plain/zstd" , + test_multifd_postcopy_tcp_zstd);#endif #ifdef CONFIG_QATZIP
tests/qtest/migration/postcopy-tests.c +27 -0
@@ -94,6 +94,29 @@ static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) } } +static void test_multifd_postcopy (void ) +{ +MigrateCommon args = { + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + }, + }; + +test_postcopy_common (&args); +} + +static void test_multifd_postcopy_preempt (void ) +{ +MigrateCommon args = { + .start = { + .caps[MIGRATION_CAPABILITY_MULTIFD ] = true, + .caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT ] = true, + }, + }; + +test_postcopy_common (&args); +} +void migration_test_add_postcopy (MigrationTestEnv *env) {migration_test_add_postcopy_smoke (env);
@@ -114,6 +137,10 @@ void migration_test_add_postcopy(MigrationTestEnv *env)"/migration/postcopy/recovery/double-failures/reconnect" , test_postcopy_recovery_fail_reconnect); +migration_test_add ("/migration/postcopy/multifd/plain" , + test_multifd_postcopy); +migration_test_add ("/migration/postcopy/multifd/preempt/plain" , + test_multifd_postcopy_preempt);if (env->is_x86) {migration_test_add ("/migration/postcopy/suspend" , test_postcopy_suspend);
tests/qtest/migration/precopy-tests.c +19 -0
@@ -34,6 +34,7 @@#define DIRTYLIMIT_TOLERANCE_RANGE 25/* MB/s */ static char *tmpfs; +static bool postcopy_ram = false;static void test_precopy_unix_plain (void ) {
@@ -476,6 +477,11 @@ static void test_multifd_tcp_cancel(void)migrate_ensure_non_converge (from);migrate_prepare_for_dirty_mem (from); +if (postcopy_ram) { +migrate_set_capability (from,"postcopy-ram" , true); +migrate_set_capability (to,"postcopy-ram" , true); + } +migrate_set_parameter_int (from,"multifd-channels" ,16 );migrate_set_parameter_int (to,"multifd-channels" ,16 );
@@ -517,6 +523,10 @@ static void test_multifd_tcp_cancel(void)return ; } +if (postcopy_ram) { +migrate_set_capability (to2,"postcopy-ram" , true); + } +migrate_set_parameter_int (to2,"multifd-channels" ,16 );migrate_set_capability (to2,"multifd" , true);
@@ -540,6 +550,13 @@ static void test_multifd_tcp_cancel(void)migrate_end (from, to2, true); } +static void test_multifd_postcopy_tcp_cancel (void ) +{ + postcopy_ram = true; +test_multifd_tcp_cancel (); + postcopy_ram = false; +} +static void test_cancel_src_after_failed (QTestState *from,QTestState *to,const char *uri,const char *phase) {
@@ -1127,6 +1144,8 @@ static void migration_test_add_precopy_smoke(MigrationTestEnv *env) test_multifd_tcp_uri_none);migration_test_add ("/migration/multifd/tcp/plain/cancel" , test_multifd_tcp_cancel); +migration_test_add ("/migration/multifd+postcopy/tcp/plain/cancel" , + test_multifd_postcopy_tcp_cancel); }void migration_test_add_precopy (MigrationTestEnv *env)
tests/qtest/migration/tls-tests.c +47 -0
77 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v8 6/7 migration: Add save_postcopy_prepare() savevm handler
In reply to Prasad PanditFrom: Peter Xu <[email protected]>
Add a savevm handler for a module to opt-in sending extra sections right before postcopy starts, and before VM is stopped.
RAM will start to use this new savevm handler in the next patch to do flush and sync for multifd pages.
Note that we choose to do it before VM stopped because the current only potential user is not sensitive to VM status, so doing it before VM is stopped is preferred to enlarge any postcopy downtime.
It is still a bit unfortunate that we need to introduce such a new savevm handler just for the only use case, however it's so far the cleanest.
--- include/migration/register.h | 15 +++++++++++++++ migration/migration.c | 4 ++++ migration/savevm.c | 33 +++++++++++++++++++++++++++++++++ migration/savevm.h | 1 + 4 files changed, 53 insertions(+)
v8:
- New patch
v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
include/migration/register.h +15 -0
@@ -189,6 +189,21 @@ typedef struct SaveVMHandlers {/* This runs outside the BQL! */ +/** +* @save_postcopy_prepare +* +* This hook will be invoked on the source side right before switching +* to postcopy (before VM stopped). +* +* @f: QEMUFile where to send the data +* @opaque: Data pointer passed to register_savevm_live() +* @errp: Error** used to report error message +* +* Returns: true if succeeded, false if error occured. When false is +* returned, @errp must be set. +*/ +bool (*save_postcopy_prepare)(QEMUFile *f,void *opaque,Error **errp); +/** * @state_pending_estimate *
migration/migration.c +4 -0
@@ -2721,6 +2721,10 @@ static int postcopy_start(MigrationState *ms, Error **errp) } } +if (!qemu_savevm_state_postcopy_prepare (ms->to_dst_file, errp)) { +return -1 ; + } +trace_postcopy_start ();bql_lock ();trace_postcopy_start_set_run ();
migration/savevm.c +33 -0
@@ -1523,6 +1523,39 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f)qemu_fflush (f); } +bool qemu_savevm_state_postcopy_prepare (QEMUFile *f,Error **errp) +{ +SaveStateEntry *se; +bool ret; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { +if (!se->ops || !se->ops->save_postcopy_prepare) { +continue ; + } + +if (se->ops->is_active) { +if (!se->ops->is_active (se->opaque)) { +continue ; + } + } + +trace_savevm_section_start (se->idstr, se->section_id); + +save_section_header (f, se,QEMU_VM_SECTION_PART ); + ret = se->ops->save_postcopy_prepare (f, se->opaque, errp); +save_section_footer (f, se); + +trace_savevm_section_end (se->idstr, se->section_id, ret); + +if (!ret) { +assert (*errp); +return false; + } + } + +return true; +} +int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy) {int64_t start_ts_each, end_ts_each;
migration/savevm.h +1 -0
@@ -45,6 +45,7 @@ void qemu_savevm_state_pending_exact(uint64_t *must_precopy,void qemu_savevm_state_pending_estimate (uint64_t *must_precopy,uint64_t *can_postcopy);int qemu_savevm_state_complete_precopy_iterable (QEMUFile *f,bool in_postcopy); +bool qemu_savevm_state_postcopy_prepare (QEMUFile *f,Error **errp);void qemu_savevm_send_ping (QEMUFile *f,uint32_t value);void qemu_savevm_send_open_return_path (QEMUFile *f);int qemu_savevm_send_packaged (QEMUFile *f,const uint8_t *buf,size_t len);
Signature · 1 line
2.48.1
Re: [PATCH v8 6/7] migration: Add save_postcopy_prepare() savevm handler
Prasad Pandit <[email protected]> writes:
This patch and the next one need to come before 3/7.
Re: [PATCH v8 6/7] migration: Add save_postcopy_prepare() savevm handler
Quoted 1 line · Fabiano Rosas
This patch and the next one need to come before 3/7.
* Okay.
Thank you.
---
- Prasad
PATCH v8 7/7 migration/ram: Implement save_postcopy_prepare()
In reply to Prasad PanditFrom: Peter Xu <[email protected]>
Implement save_postcopy_prepare(), preparing for the enablement of both multifd and postcopy.
Please see the rich comment for the rationals.
--- migration/ram.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
v8:
- New patch
v7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/ram.c +37 -0
@@ -4419,6 +4419,42 @@ static int ram_resume_prepare(MigrationState *s, void *opaque)return 0 ; } +static bool ram_save_postcopy_prepare (QEMUFile *f,void *opaque,Error **errp) +{ +int ret; + +if (migrate_multifd ()) { +/* +* When multifd is enabled, source QEMU needs to make sure all the +* pages queued before postcopy starts to be flushed. +* +* Meanwhile, the load of these pages must happen before switching +* to postcopy. It's because loading of guest pages (so far) in +* multifd recv threads is still non-atomic, so the load cannot +* happen with vCPUs running on destination side. +* +* This flush and sync will guarantee those pages loaded _before_ +* postcopy starts on destination. The rational is, this happens +* before VM stops (and before source QEMU sends all the rest of +* the postcopy messages). So when the destination QEMU received +* the postcopy messages, it must have received the sync message on +* the main channel (either RAM_SAVE_FLAG_MULTIFD_FLUSH, or +* RAM_SAVE_FLAG_EOS), and such message should have guaranteed all +* previous guest pages queued in the multifd channels to be +* completely loaded. +*/ + ret =multifd_ram_flush_and_sync (f); +if (ret <0 ) { +error_setg (errp,"%s: multifd flush and sync failed" , __func__); +return false; + } + } + +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + +return true; +} +void postcopy_preempt_shutdown_file (MigrationState *s) {qemu_put_be64 (s->postcopy_qemufile_src,RAM_SAVE_FLAG_EOS );
@@ -4438,6 +4474,7 @@ static SaveVMHandlers savevm_ram_handlers = { .load_setup = ram_load_setup, .load_cleanup = ram_load_cleanup, .resume_prepare = ram_resume_prepare, + .save_postcopy_prepare = ram_save_postcopy_prepare, }; static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host,
Signature · 1 line
2.48.1
Re: [PATCH v8 7/7] migration/ram: Implement save_postcopy_prepare()
Quoted 25 lines · Prasad Pandit
From: Peter Xu <[email protected]>
Implement
save_postcopy_prepare(), preparing for the enablement of both multifd and postcopy.Please see the rich comment for the rationals.
Signed-off-by Peter Xu <[email protected]>Signed-off-by Prasad Pandit <[email protected]>--- migration/ram.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)v8:
- New patchv7:
- https://lore.kernel.org/qemu-devel/[email protected]/T/#tmigration/ram.c +0
-0@@ -4419,6 +4419,42 @@ static int ram_resume_prepare(MigrationState *s, void *opaque)return 0 ;
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4429
Quoted 10 lines
migration/ram.c +8
-0} +static bool ram_save_postcopy_prepare (QEMUFile *f,void *opaque,Error **errp) +{ +int ret; + +if (migrate_multifd ()) { +/* +* When multifd is enabled, source QEMU needs to make sure all the +* pages queued before postcopy starts to be flushed.
s/to be/have been/
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4431
Quoted 2 lines
migration/ram.c +2
-0+* +* Meanwhile, the load of these pages must happen before switching
s/Meanwhile,//
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4436
Quoted 5 lines
migration/ram.c +5
-0+* to postcopy. It's because loading of guest pages (so far) in +* multifd recv threads is still non-atomic, so the load cannot +* happen with vCPUs running on destination side. +* +* This flush and sync will guarantee those pages loaded _before_
s/loaded/are loaded/
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4437
Quoted 1 line
migration/ram.c +1
-0+* postcopy starts on destination. The rational is, this happens
s/rational/rationale/
Quoted 31 lines
migration/ram.c +21
-0+* before VM stops (and before source QEMU sends all the rest of +* the postcopy messages). So when the destination QEMU received +* the postcopy messages, it must have received the sync message on +* the main channel (either RAM_SAVE_FLAG_MULTIFD_FLUSH, or +* RAM_SAVE_FLAG_EOS), and such message should have guaranteed all +* previous guest pages queued in the multifd channels to be +* completely loaded. +*/ + ret =multifd_ram_flush_and_sync (f); +if (ret <0 ) { +error_setg (errp,"%s: multifd flush and sync failed" , __func__); +return false; + } + } + +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + +return true; +} +void postcopy_preempt_shutdown_file (MigrationState *s) {qemu_put_be64 (s->postcopy_qemufile_src,RAM_SAVE_FLAG_EOS );@@ -4438,6 +4474,7 @@ static SaveVMHandlers savevm_ram_handlers = { .load_setup = ram_load_setup, .load_cleanup = ram_load_cleanup, .resume_prepare = ram_resume_prepare, + .save_postcopy_prepare = ram_save_postcopy_prepare, }; static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host,
Re: [PATCH v8 7/7] migration/ram: Implement save_postcopy_prepare()
Hi,
Quoted 22 lines · Fabiano Rosas
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4429
Quoted 8 lines
migration/ram.c +8
-0+static bool ram_save_postcopy_prepare (QEMUFile *f,void *opaque,Error **errp) +{ +int ret; + +if (migrate_multifd ()) { +/* +* When multifd is enabled, source QEMU needs to make sure all the +* pages queued before postcopy starts to be flushed. s/to be/have been/
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4431
Quoted 2 lines
migration/ram.c +2
-0+* +* Meanwhile, the load of these pages must happen before switching s/Meanwhile,//
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4436
Quoted 5 lines
migration/ram.c +5
-0+* to postcopy. It's because loading of guest pages (so far) in +* multifd recv threads is still non-atomic, so the load cannot +* happen with vCPUs running on destination side. +* +* This flush and sync will guarantee those pages loaded _before_
Quoted 14 lines
s/loaded/are loaded/
Quoted 1 line
+ * postcopy starts on destination. The rational is, this happens
s/rational/rationale/
Quoted 8 lines
migration/ram.c +8
-0+* before VM stops (and before source QEMU sends all the rest of +* the postcopy messages). So when the destination QEMU received +* the postcopy messages, it must have received the sync message on +* the main channel (either RAM_SAVE_FLAG_MULTIFD_FLUSH, or +* RAM_SAVE_FLAG_EOS), and such message should have guaranteed all +* previous guest pages queued in the multifd channels to be +* completely loaded. +*/
* I'll include the above suggested corrections. I'm thinking it might help more to have such an explanatory comment at the definition of the multifd_ram_flush_and_sync() routine. Because looking at that function it is not clear how 'MULTIFD_SYNC_ALL' is used. It sets the '->pending_sync' to MULTIFD_SYNC_CALL. And when '->pending_sync' is set this way, multifd_send_thread() writes 'MULTIFD_FLAG_SYNC' on each multifd channel. At the destination this 'MULTIFD_FLAG_SYNC' flag is then used to sync main and multifd_recv threads.
...wdyt?
Thank you.
---
- Prasad
Re: [PATCH v8 7/7] migration/ram: Implement save_postcopy_prepare()
Quoted 49 lines · Prasad Pandit
Hi,
Quoted 22 lines · Fabiano Rosas
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4429
Quoted 8 lines
migration/ram.c +8
-0+static bool ram_save_postcopy_prepare (QEMUFile *f,void *opaque,Error **errp) +{ +int ret; + +if (migrate_multifd ()) { +/* +* When multifd is enabled, source QEMU needs to make sure all the +* pages queued before postcopy starts to be flushed. s/to be/have been/
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4431
Quoted 2 lines
migration/ram.c +2
-0+* +* Meanwhile, the load of these pages must happen before switching s/Meanwhile,//
migration/ram.c static int ram_resume_prepare(MigrationState *s, void *opaque) · line 4436
Quoted 5 lines
migration/ram.c +5
-0+* to postcopy. It's because loading of guest pages (so far) in +* multifd recv threads is still non-atomic, so the load cannot +* happen with vCPUs running on destination side. +* +* This flush and sync will guarantee those pages loaded _before_ Quoted 14 lines
s/loaded/are loaded/
Quoted 1 line
+ * postcopy starts on destination. The rational is, this happens
s/rational/rationale/
Quoted 8 lines
migration/ram.c +8
-0+* before VM stops (and before source QEMU sends all the rest of +* the postcopy messages). So when the destination QEMU received +* the postcopy messages, it must have received the sync message on +* the main channel (either RAM_SAVE_FLAG_MULTIFD_FLUSH, or +* RAM_SAVE_FLAG_EOS), and such message should have guaranteed all +* previous guest pages queued in the multifd channels to be +* completely loaded. +*/ * I'll include the above suggested corrections. I'm thinking it might help more to have such an explanatory comment at the definition of the
multifd_ram_flush_and_sync()routine. Because looking at that function it is not clear how 'MULTIFD_SYNC_ALL' is used. It sets the '->pending_sync' toMULTIFD_SYNC_CALL. And when '->pending_sync' is set this way,multifd_send_thread()writes 'MULTIFD_FLAG_SYNC' on each multifd channel. At the destination this 'MULTIFD_FLAG_SYNC' flag is then used to sync main andmultifd_recvthreads.
Quoted 1 line
...wdyt?
The code assumes some understanding of the multifd sync in general. It doesn't help that we don't have a high level documentation for that (yet). If you think the comments at the MultiFDSyncReq are not enough, feel free to propose a separate patch adding documentation to multifd_ram_flush_and_sync().
Quoted 4 lines
Thank you.
---
- Prasad
Re: [PATCH v8 7/7] migration/ram: Implement save_postcopy_prepare()
Quoted 5 lines · Fabiano Rosas
The code assumes some understanding of the multifd sync in general. It doesn't help that we don't have a high level documentation for that (yet). If you think the comments at the MultiFDSyncReq are not enough, feel free to propose a separate patch adding documentation to
multifd_ram_flush_and_sync().
Okay, will check. Thank you.
---
- Prasad
Hello Fabiano,
Quoted 5 lines · Prasad Pandit
* This series (v8) splits earlier patch-2 which enabled multifd and postcopy options together into two separate patches. One modifies the channel discovery in
migration_ioc_process_incoming()function, and second one enables the multifd and postcopy migration together.
Quoted 7 lines
It also adds the '
save_postcopy_prepare'savevm_statehandler to enable different sections to take an action just before the Postcopy phase starts. Thank you Peter for these patches.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 152.66s 81 subtests passed
===
Ping..! Did you have chance to review this (v8) series. (just checking)
Thank you.
---
- Prasad
Quoted 16 lines · Prasad Pandit
Hello Fabiano,
Quoted 5 lines · Prasad Pandit
* This series (v8) splits earlier patch-2 which enabled multifd and postcopy options together into two separate patches. One modifies the channel discovery in
migration_ioc_process_incoming()function, and second one enables the multifd and postcopy migration together.Quoted 7 lines
It also adds the '
save_postcopy_prepare'savevm_statehandler to enable different sections to take an action just before the Postcopy phase starts. Thank you Peter for these patches.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 152.66s 81 subtests passed
===
Quoted 2 lines
Ping..! Did you have chance to review this (v8) series. (just checking)
I'll get to it soon. I need to send a PR for the recent SNP breakage and also check Li Zhijian's RDMA series first.
Quoted 2 lines · Fabiano Rosas
I'll get to it soon. I need to send a PR for the recent SNP breakage and also check Li Zhijian's RDMA series first.
* I see, okay. Thank you for an update, I appreciate it.
Thank you.
---
- Prasad
Quoted 9 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Hello,
* This series (v8) splits earlier patch-2 which enabled multifd and postcopy options together into two separate patches. One modifies the channel discovery in
migration_ioc_process_incoming()function, and second one enables the multifd and postcopy migration together.
Quoted 5 lines
It also adds the '
save_postcopy_prepare'savevm_statehandler to enable different sections to take an action just before the Postcopy phase starts. Thank you Peter for these patches.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 152.66s 81 subtests passed
The postcopy/multifd/plain test is still hanging from time to time. I see a vmstate load function trying to access guest memory and the postcopy-listen thread already finished, waiting for that qemu_loadvm_state() (frame #18) to return and set the main_thread_load_event.
Thread 1 (Thread 0x7fbc4849df80 (LWP 7487) "qemu-system-x86"):
#0 __memcpy_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:274 #1 0x0000560b135103aa in flatview_read_continue_step (attrs=..., buf=0x560b168a5930 "U\252\022\006\016\a1\300\271", len=9216, mr_addr=831488, l=0x7fbc465ff980, mr=0x560b166c5070) at ../system/physmem.c:3056 #2 0x0000560b1351042e in flatview_read_continue (fv=0x560b16c606a0, addr=831488, attrs=..., ptr=0x560b168a5930, len=9216, mr_addr=831488, l=9216, mr=0x560b166c5070) at ../system/physmem.c:3073 #3 0x0000560b13510533 in flatview_read (fv=0x560b16c606a0, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3103 #4 0x0000560b135105be in address_space_read_full (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3116 #5 0x0000560b135106e7 in address_space_rw (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3144 #6 0x0000560b13510848 in cpu_physical_memory_rw (addr=831488, buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3170 #7 0x0000560b1338f5a5 in cpu_physical_memory_read (addr=831488, buf=0x560b168a5930, len=9216) at qemu/include/exec/cpu-common.h:148 #8 0x0000560b1339063c in patch_hypercalls (s=0x560b168840c0) at ../hw/i386/vapic.c:547 #9 0x0000560b1339096d in vapic_prepare (s=0x560b168840c0) at ../hw/i386/vapic.c:629
#10 0x0000560b13390e8b in vapic_post_load (opaque=0x560b168840c0, version_id=1) at ../hw/i386/vapic.c:789
#11 0x0000560b135b4924 in vmstate_load_state (f=0x560b16c53400, vmsd=0x560b147c6cc0 <vmstate_vapic>, opaque=0x560b168840c0, version_id=1) at ../migration/vmstate.c:234 #12 0x0000560b132a15b8 in vmstate_load (f=0x560b16c53400, se=0x560b16893390) at ../migration/savevm.c:972
#13 0x0000560b132a4f28 in qemu_loadvm_section_start_full (f=0x560b16c53400, type=4 '\004') at ../migration/savevm.c:2746
#14 0x0000560b132a5ae8 in qemu_loadvm_state_main (f=0x560b16c53400, mis=0x560b16877f20) at ../migration/savevm.c:3058
#15 0x0000560b132a45d0 in loadvm_handle_cmd_packaged (mis=0x560b16877f20) at ../migration/savevm.c:2451
#16 0x0000560b132a4b36 in loadvm_process_command (f=0x560b168c3b60) at ../migration/savevm.c:2614
#17 0x0000560b132a5b96 in qemu_loadvm_state_main (f=0x560b168c3b60, mis=0x560b16877f20) at ../migration/savevm.c:3073
#18 0x0000560b132a5db7 in qemu_loadvm_state (f=0x560b168c3b60) at ../migration/savevm.c:3150
#19 0x0000560b13286271 in process_incoming_migration_co (opaque=0x0) at ../migration/migration.c:892
#20 0x0000560b137cb6d4 in coroutine_trampoline (i0=377836416, i1=22027) at ../util/coroutine-ucontext.c:175
#21 0x00007fbc4786a79e in ??? () at ../sysdeps/unix/sysv/linux/x86_64/__start_context.S:103
Thread 10 (Thread 0x7fffce7fc700 (LWP 11778) "mig/dst/listen"):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 #1 0x000055555614e33f in qemu_futex_wait (f=0x5555576f6fc0, val=4294967295) at qemu/include/qemu/futex.h:29 #2 0x000055555614e505 in qemu_event_wait (ev=0x5555576f6fc0) at ../util/qemu-thread-posix.c:464 #3 0x0000555555c44eb1 in postcopy_ram_listen_thread (opaque=0x5555576f6f20) at ../migration/savevm.c:2135 #4 0x000055555614e6b8 in qemu_thread_start (args=0x5555582c8480) at ../util/qemu-thread-posix.c:541 #5 0x00007ffff72626ea in start_thread (arg=0x7fffce7fc700) at pthread_create.c:477 #6 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Thread 9 (Thread 0x7fffceffd700 (LWP 11777) "mig/dst/fault"):
#0 0x00007ffff5314a89 in __GI___poll (fds=0x7fffc0000b60, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x0000555555c3be3f in postcopy_ram_fault_thread (opaque=0x5555576f6f20) at ../migration/postcopy-ram.c:999 #2 0x000055555614e6b8 in qemu_thread_start (args=0x555557735be0) at ../util/qemu-thread-posix.c:541 #3 0x00007ffff72626ea in start_thread (arg=0x7fffceffd700) at pthread_create.c:477 #4 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Breaking with gdb and stepping through the memcpy code generates a request for a page that's seemingly already in the receivedmap:
(gdb) x/i $pc
=> 0x7ffff5399d14 <__memcpy_evex_unaligned_erms+86>: rep movsb %ds:(%rsi),%es:(%rdi)
(gdb) p/x $rsi
$1 = 0x7fffd68cc000
(gdb) sipostcopy_ram_fault_thread_request Request for HVA=0x7fffd68cc000 rb=pc.ram offset=0xcc000 pid=11754 // these are my printfs:postcopy_request_page:migrate_send_rp_req_pages:migrate_send_rp_req_pages: mutexmigrate_send_rp_req_pages: received
// gdb hangs here, it looks like the page wasn't populated?
I've had my share of postcopy for the day. Hopefully you'll be able to figure out what the issue is.
- reproducer (2nd iter already hangs for me):
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; done
- reproducer with traces and gdb:
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_TRACE="multifd_* -trace source_* -trace postcopy_* -trace savevm_* \ -trace loadvm_*" QTEST_QEMU_BINARY_DST='gdb --ex "handle SIGUSR1 \ noprint" --ex "run" --args ./qemu-system-x86_64' \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; done
Quoted 73 lines · Fabiano Rosas
The postcopy/multifd/plain test is still hanging from time to time. I see a vmstate load function trying to access guest memory and the postcopy-listen thread already finished, waiting for that
qemu_loadvm_state()(frame #18) to return and set themain_thread_load_event.Thread 1 (Thread
0x7fbc4849df80(LWP 7487) "qemu-system-x86"):#0 __memcpy_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:274 #1 0x0000560b135103aa in flatview_read_continue_step (attrs=..., buf=0x560b168a5930 "U\252\022\006\016\a1\300\271", len=9216, mr_addr=831488, l=0x7fbc465ff980, mr=0x560b166c5070) at ../system/physmem.c:3056 #2 0x0000560b1351042e in flatview_read_continue (fv=0x560b16c606a0, addr=831488, attrs=..., ptr=0x560b168a5930, len=9216, mr_addr=831488, l=9216, mr=0x560b166c5070) at ../system/physmem.c:3073 #3 0x0000560b13510533 in flatview_read (fv=0x560b16c606a0, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3103 #4 0x0000560b135105be in address_space_read_full (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3116 #5 0x0000560b135106e7 in address_space_rw (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3144 #6 0x0000560b13510848 in cpu_physical_memory_rw (addr=831488, buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3170 #7 0x0000560b1338f5a5 in cpu_physical_memory_read (addr=831488, buf=0x560b168a5930, len=9216) at qemu/include/exec/cpu-common.h:148 #8 0x0000560b1339063c in patch_hypercalls (s=0x560b168840c0) at ../hw/i386/vapic.c:547 #9 0x0000560b1339096d in vapic_prepare (s=0x560b168840c0) at ../hw/i386/vapic.c:629#10
0x0000560b13390e8binvapic_post_load(opaque=0x560b168840c0, version_id=1) at../hw/i386/vapic.c:789
#110x0000560b135b4924invmstate_load_state(f=0x560b16c53400, vmsd=0x560b147c6cc0 <vmstate_vapic>, opaque=0x560b168840c0, version_id=1) at../migration/vmstate.c:234#120x0000560b132a15b8invmstate_load(f=0x560b16c53400, se=0x560b16893390) at../migration/savevm.c:972
#130x0000560b132a4f28inqemu_loadvm_section_start_full(f=0x560b16c53400, type=4 '\004') at../migration/savevm.c:2746
#140x0000560b132a5ae8inqemu_loadvm_state_main(f=0x560b16c53400, mis=0x560b16877f20) at../migration/savevm.c:3058
#150x0000560b132a45d0inloadvm_handle_cmd_packaged(mis=0x560b16877f20) at../migration/savevm.c:2451
#160x0000560b132a4b36inloadvm_process_command(f=0x560b168c3b60) at../migration/savevm.c:2614
#170x0000560b132a5b96inqemu_loadvm_state_main(f=0x560b168c3b60, mis=0x560b16877f20) at../migration/savevm.c:3073
#180x0000560b132a5db7inqemu_loadvm_state(f=0x560b168c3b60) at../migration/savevm.c:3150
#190x0000560b13286271inprocess_incoming_migration_co(opaque=0x0) at../migration/migration.c:892
#200x0000560b137cb6d4incoroutine_trampoline(i0=377836416, i1=22027) at../util/coroutine-ucontext.c:175
#210x00007fbc4786a79ein ??? () at../sysdeps/unix/sysv/linux/x86_64/__start_context.S:103Thread 10 (Thread
0x7fffce7fc700(LWP 11778) "mig/dst/listen"):#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 #1 0x000055555614e33f in qemu_futex_wait (f=0x5555576f6fc0, val=4294967295) at qemu/include/qemu/futex.h:29 #2 0x000055555614e505 in qemu_event_wait (ev=0x5555576f6fc0) at ../util/qemu-thread-posix.c:464 #3 0x0000555555c44eb1 in postcopy_ram_listen_thread (opaque=0x5555576f6f20) at ../migration/savevm.c:2135 #4 0x000055555614e6b8 in qemu_thread_start (args=0x5555582c8480) at ../util/qemu-thread-posix.c:541 #5 0x00007ffff72626ea in start_thread (arg=0x7fffce7fc700) at pthread_create.c:477 #6 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95Thread 9 (Thread
0x7fffceffd700(LWP 11777) "mig/dst/fault"):#0 0x00007ffff5314a89 in __GI___poll (fds=0x7fffc0000b60, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x0000555555c3be3f in postcopy_ram_fault_thread (opaque=0x5555576f6f20) at ../migration/postcopy-ram.c:999 #2 0x000055555614e6b8 in qemu_thread_start (args=0x555557735be0) at ../util/qemu-thread-posix.c:541 #3 0x00007ffff72626ea in start_thread (arg=0x7fffceffd700) at pthread_create.c:477 #4 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95Breaking with gdb and stepping through the memcpy code generates a request for a page that's seemingly already in the receivedmap:
(gdb) x/i $pc
=>0x7ffff5399d14<__memcpy_evex_unaligned_erms+86>: rep movsb %ds:(%rsi),%es:(%rdi)
(gdb) p/x $rsi
$1 =0x7fffd68cc000
(gdb) sipostcopy_ram_fault_thread_requestRequest for HVA=0x7fffd68cc000 rb=pc.ram offset=0xcc000 pid=11754 // these are my printfs:postcopy_request_page:migrate_send_rp_req_pages:migrate_send_rp_req_pages: mutexmigrate_send_rp_req_pages: received// gdb hangs here, it looks like the page wasn't populated?
I've had my share of postcopy for the day. Hopefully you'll be able to figure out what the issue is.
- reproducer (2nd iter already hangs for me):
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; done
Quoted 8 lines
- reproducer with traces and gdb:
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_TRACE="multifd_* -trace source_* -trace postcopy_* -trace savevm_* \ -trace loadvm_*" QTEST_QEMU_BINARY_DST='gdb --ex "handle SIGUSR1 \ noprint" --ex "run" --args ./qemu-system-x86_64' \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; done
* Thank you for the reproducer and traces. I'll try to check more and see if I'm able to reproduce it on my side.
Thank you.
---
- Prasad
Quoted 83 lines · Prasad Pandit
Quoted 73 lines · Fabiano Rosas
The postcopy/multifd/plain test is still hanging from time to time. I see a vmstate load function trying to access guest memory and the postcopy-listen thread already finished, waiting for that
qemu_loadvm_state()(frame #18) to return and set themain_thread_load_event.Thread 1 (Thread
0x7fbc4849df80(LWP 7487) "qemu-system-x86"):#0 __memcpy_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:274 #1 0x0000560b135103aa in flatview_read_continue_step (attrs=..., buf=0x560b168a5930 "U\252\022\006\016\a1\300\271", len=9216, mr_addr=831488, l=0x7fbc465ff980, mr=0x560b166c5070) at ../system/physmem.c:3056 #2 0x0000560b1351042e in flatview_read_continue (fv=0x560b16c606a0, addr=831488, attrs=..., ptr=0x560b168a5930, len=9216, mr_addr=831488, l=9216, mr=0x560b166c5070) at ../system/physmem.c:3073 #3 0x0000560b13510533 in flatview_read (fv=0x560b16c606a0, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3103 #4 0x0000560b135105be in address_space_read_full (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216) at ../system/physmem.c:3116 #5 0x0000560b135106e7 in address_space_rw (as=0x560b14970fc0 <address_space_memory>, addr=831488, attrs=..., buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3144 #6 0x0000560b13510848 in cpu_physical_memory_rw (addr=831488, buf=0x560b168a5930, len=9216, is_write=false) at ../system/physmem.c:3170 #7 0x0000560b1338f5a5 in cpu_physical_memory_read (addr=831488, buf=0x560b168a5930, len=9216) at qemu/include/exec/cpu-common.h:148 #8 0x0000560b1339063c in patch_hypercalls (s=0x560b168840c0) at ../hw/i386/vapic.c:547 #9 0x0000560b1339096d in vapic_prepare (s=0x560b168840c0) at ../hw/i386/vapic.c:629#10
0x0000560b13390e8binvapic_post_load(opaque=0x560b168840c0, version_id=1) at../hw/i386/vapic.c:789
#110x0000560b135b4924invmstate_load_state(f=0x560b16c53400, vmsd=0x560b147c6cc0 <vmstate_vapic>, opaque=0x560b168840c0, version_id=1) at../migration/vmstate.c:234#120x0000560b132a15b8invmstate_load(f=0x560b16c53400, se=0x560b16893390) at../migration/savevm.c:972
#130x0000560b132a4f28inqemu_loadvm_section_start_full(f=0x560b16c53400, type=4 '\004') at../migration/savevm.c:2746
#140x0000560b132a5ae8inqemu_loadvm_state_main(f=0x560b16c53400, mis=0x560b16877f20) at../migration/savevm.c:3058
#150x0000560b132a45d0inloadvm_handle_cmd_packaged(mis=0x560b16877f20) at../migration/savevm.c:2451
#160x0000560b132a4b36inloadvm_process_command(f=0x560b168c3b60) at../migration/savevm.c:2614
#170x0000560b132a5b96inqemu_loadvm_state_main(f=0x560b168c3b60, mis=0x560b16877f20) at../migration/savevm.c:3073
#180x0000560b132a5db7inqemu_loadvm_state(f=0x560b168c3b60) at../migration/savevm.c:3150
#190x0000560b13286271inprocess_incoming_migration_co(opaque=0x0) at../migration/migration.c:892
#200x0000560b137cb6d4incoroutine_trampoline(i0=377836416, i1=22027) at../util/coroutine-ucontext.c:175
#210x00007fbc4786a79ein ??? () at../sysdeps/unix/sysv/linux/x86_64/__start_context.S:103Thread 10 (Thread
0x7fffce7fc700(LWP 11778) "mig/dst/listen"):#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 #1 0x000055555614e33f in qemu_futex_wait (f=0x5555576f6fc0, val=4294967295) at qemu/include/qemu/futex.h:29 #2 0x000055555614e505 in qemu_event_wait (ev=0x5555576f6fc0) at ../util/qemu-thread-posix.c:464 #3 0x0000555555c44eb1 in postcopy_ram_listen_thread (opaque=0x5555576f6f20) at ../migration/savevm.c:2135 #4 0x000055555614e6b8 in qemu_thread_start (args=0x5555582c8480) at ../util/qemu-thread-posix.c:541 #5 0x00007ffff72626ea in start_thread (arg=0x7fffce7fc700) at pthread_create.c:477 #6 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95Thread 9 (Thread
0x7fffceffd700(LWP 11777) "mig/dst/fault"):#0 0x00007ffff5314a89 in __GI___poll (fds=0x7fffc0000b60, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x0000555555c3be3f in postcopy_ram_fault_thread (opaque=0x5555576f6f20) at ../migration/postcopy-ram.c:999 #2 0x000055555614e6b8 in qemu_thread_start (args=0x555557735be0) at ../util/qemu-thread-posix.c:541 #3 0x00007ffff72626ea in start_thread (arg=0x7fffceffd700) at pthread_create.c:477 #4 0x00007ffff532158f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95Breaking with gdb and stepping through the memcpy code generates a request for a page that's seemingly already in the receivedmap:
(gdb) x/i $pc
=>0x7ffff5399d14<__memcpy_evex_unaligned_erms+86>: rep movsb %ds:(%rsi),%es:(%rdi)
(gdb) p/x $rsi
$1 =0x7fffd68cc000
(gdb) sipostcopy_ram_fault_thread_requestRequest for HVA=0x7fffd68cc000 rb=pc.ram offset=0xcc000 pid=11754 // these are my printfs:postcopy_request_page:migrate_send_rp_req_pages:migrate_send_rp_req_pages: mutexmigrate_send_rp_req_pages: received// gdb hangs here, it looks like the page wasn't populated?
I've had my share of postcopy for the day. Hopefully you'll be able to figure out what the issue is.
- reproducer (2nd iter already hangs for me):
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; doneQuoted 8 lines
- reproducer with traces and gdb:
$ for i in $(seq 1 9999); do echo "$i ============="; \ QTEST_TRACE="multifd_* -trace source_* -trace postcopy_* -trace savevm_* \ -trace loadvm_*" QTEST_QEMU_BINARY_DST='gdb --ex "handle SIGUSR1 \ noprint" --ex "run" --args ./qemu-system-x86_64' \ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test \ --full -r /x86_64/migration/postcopy/multifd/plain || break ; done
Quoted 3 lines
* Thank you for the reproducer and traces. I'll try to check more and see if I'm able to reproduce it on my side.
Thanks. I cannot merge this series until that issue is resolved. If it reproduces on my machine there's a high chance that it will break CI at some point and then it'll be a nightmare to debug. This has happened many times before with multifd.
Quoted 3 lines
Thank you.
---
- Prasad
Hello Fabiano,
Quoted 8 lines · Fabiano Rosas
Quoted 2 lines · Prasad Pandit
* Thank you for the reproducer and traces. I'll try to check more and see if I'm able to reproduce it on my side.
Thanks. I cannot merge this series until that issue is resolved. If it reproduces on my machine there's a high chance that it will break CI at some point and then it'll be a nightmare to debug. This has happened many times before with multifd.
===
qemu/build)$ for i in $(seq 1 9999); do echo "$i ===="; QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r '/x86_64/migration/postcopy/multifd/plain' || break; done | tee /tmp/migration-test.out | awk -e '/====/ { printf ("%s ", $_) }; /slow test/ { printf("%s\n", $_); }'
Host-1]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.42 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.56 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.43 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.46 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.41 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.42 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.58 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
--------
Iter: 9999, low: 1.35, high: 1.73, avg: 1.47 secs
Host-2]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.69 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.41 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.37 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
--------
Iter: 9999, low: 1.34, high: 1.82, avg: 1.48 secs
Host-3]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.55 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.52 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.52 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
--------
Iter: 9999, low: 1.31, high: 2.49, avg: 1.48
===
* I tried to reproduce the hang issue with and without -traces across 3 different machines but am unable to reproduce it on my side.
* Going through the source and the back trace you provided, you said gdb hangs in the postcopy_ram_fault_thread() function at poll() function to wait for a missing page.
- But by this time, postcopy_ram_listen thread is already preparing
to cleanup and exit
- That means postcopy migration is finished/ending
- ie. postcopy migration is ending without (or before) migrating
all the RAM pages from the source side?
In postcopy mode:
* Is there a way to log the pages (#numers) that are sent from the
source side?
* And log the pages (#numbers) that are received on the receive side?
* That way we might be able to check/confirm the pages which were not received or not processed properly.
* Can we connect the faulting/missing (HVA=0x7fffd68cc000) address/page in postcopy_ram_fault_thread() with the memcpy that the main thread seems to be loading via vapic_post_load()? ie. the main thread and pocyopy_ram_fault_thread() above could be doing unrelated things.
* Other than this, I've revised the patch-set as suggested. How do we proceed further?
Thank you.
---
- Prasad
Quoted 160 lines · Prasad Pandit
Hello Fabiano,
Quoted 8 lines · Fabiano Rosas
Quoted 2 lines · Prasad Pandit
* Thank you for the reproducer and traces. I'll try to check more and see if I'm able to reproduce it on my side.
Thanks. I cannot merge this series until that issue is resolved. If it reproduces on my machine there's a high chance that it will break CI at some point and then it'll be a nightmare to debug. This has happened many times before with multifd.
===
qemu/build)$ for i in $(seq 1 9999); do echo "$i ===="; QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r '/x86_64/migration/postcopy/multifd/plain' || break; done | tee/tmp/migration-test.out| awk -e '/====/ { printf ("%s ", $_) }; /slow test/ {printf("%s\n", $_); }'Host-1]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.42 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.56 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.43 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.46 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.41 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.42 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.58 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
--------
Iter: 9999, low: 1.35, high: 1.73, avg: 1.47 secsHost-2]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.69 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.41 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.37 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.45 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.47 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
--------
Iter: 9999, low: 1.34, high: 1.82, avg: 1.48 secsHost-3]
...
9980 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9981 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.55 secs
9982 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9983 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9984 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9985 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.52 secs
9986 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9987 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.52 secs
9988 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9989 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9990 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.51 secs
9991 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9992 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9993 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.50 secs
9994 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.53 secs
9995 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.49 secs
9996 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.48 secs
9997 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
9998 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.44 secs
9999 ==== # slow test /x86_64/migration/postcopy/multifd/plain executed in 1.54 secs
--------
Iter: 9999, low: 1.31, high: 2.49, avg: 1.48
===* I tried to reproduce the hang issue with and without -traces across 3 different machines but am unable to reproduce it on my side.
Quoted 9 lines
* Going through the source and the back trace you provided, you said gdb hangs in the
postcopy_ram_fault_thread()function atpoll()function to wait for a missing page.
- But by this time,postcopy_ram_listenthread is already preparing
to cleanup and exit
- That means postcopy migration is finished/ending
- ie. postcopy migration is ending without (or before) migrating
all the RAM pages from the source side?
That's what it looks like. It could be some error condition that is not being propagated properly. The thread hits an error and exits without informing the rest of migration.
Quoted 7 lines
In postcopy mode:
* Is there a way to log the pages (#numers) that are sent from the
source side?
* And log the pages (#numbers) that are received on the receive side?* That way we might be able to check/confirm the pages which were not received or not processed properly.
Some combination of the postcopy traces should give you that. Sorry, Peter Xu really is the expert on postcopy, I just tag along.
Quoted 7 lines
* Can we connect the faulting/missing (HVA=0x7fffd68cc000) address/page in
postcopy_ram_fault_thread()with the memcpy that the main thread seems to be loading viavapic_post_load()? ie. the main thread andpocyopy_ram_fault_thread()above could be doing unrelated things.
The snippet I posted shows that it's the same page:
(gdb) x/i $pc
=> 0x7ffff5399d14 <__memcpy_evex_unaligned_erms+86>: rep movsb %ds:(%rsi),%es:(%rdi)
(gdb) p/x $rsi
$1 = 0x7fffd68cc000
Quoted 2 lines
* Other than this, I've revised the patch-set as suggested. How do we proceed further?
Send your next version and I'll set some time aside to debug this.
heads-up: I'll be off from 2025/04/18 until 2025/05/05. Peter should be already back in the meantime.
Quoted 4 lines
Thank you.
---
- Prasad
Hi,
Quoted 3 lines · Fabiano Rosas
That's what it looks like. It could be some error condition that is not being propagated properly. The thread hits an error and exits without informing the rest of migration.
* The gdb(1) hanging in the postcopy_ram_fault_thread() is not conclusive. I tried to set following break-points
gdb) break postcopy-ram.c:998 - poll_result = poll(pfd, pfd_len,
-1 /* Wait forever */);
gdb) break postcopy-ram.c:1057 - rb = qemu_ram_block_from_host(...); gdb(1) hangs for both of them, there might be another reason for it.
Live-migration also stalls with it.
Quoted 2 lines
Some combination of the postcopy traces should give you that. Sorry, Peter Xu really is the expert on postcopy, I just tag along.
* I see. Maybe it could be logged with --migration-debug=<level> option.
Quoted 7 lines
The snippet I posted shows that it's the same page:
(gdb) x/i $pc
=>0x7ffff5399d14<__memcpy_evex_unaligned_erms+86>: rep movsb %ds:(%rsi),%es:(%rdi)
(gdb) p/x $rsi
$1 =0x7fffd68cc000
===
Quoted 1 line
Quoted 1 line
Thread 1 (Thread
0x7fbc4849df80(LWP 7487) "qemu-system-x86"):
...
Quoted 1 line
Quoted 1 line
Thread 10 (Thread
0x7fffce7fc700(LWP 11778) "mig/dst/listen"):
...
Quoted 1 line
Quoted 1 line
Thread 9 (Thread
0x7fffceffd700(LWP 11777) "mig/dst/fault"):
#0 0x00007ffff5314a89 in __GI___poll (fds=0x7fffc0000b60, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
...postcopy_ram_fault_thread_request Request for HVA=0x7fffd68cc000 rb=pc.ram offset=0xcc000 pid=11754
===
* Looking at the above data, it seems the missing page fault occurred in thread=11754 , it may not be the memcpy(3) in thread-1(pid/tid=7487) that triggered the fault.
* Secondly, if 'mig/dst/fault' thread is waiting at poll(2) call, ie. fault notification has not arrived on the mis->userfault_fd OR mis->userfault_event_fd descriptors yet. So the "Request for HVA=0x7fffd..." via postcopy_ram_fault_thread_request() could be an already served request.
Quoted 4 lines
Send your next version and I'll set some time aside to debug this.
heads-up: I'll be off from 2025/04/18 until 2025/05/05. Peter should be already back in the meantime.
* Okay, I'll send the next version.
Thank you.
---
- Prasad