Allow to enable multifd and postcopy migration together
v9 cover Allow to enable multifd and postcopy migration together
From: Prasad Pandit <[email protected]>
Hello,
* This series (v9) does minor refactoring and reordering changes as suggested in the review of earlier series (v8). Also tried to reproduce/debug a qtest hang issue, but it could not be reproduced. From the shared stack traces it looked like Postcopy thread was preparing to finish before migrating all the pages.
===
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 170.50s 81 subtests passed
===
v8: https://lore.kernel.org/qemu-devel/[email protected]/T/#t
* 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 | 136 ++++++++++++---------- migration/multifd-nocomp.c | 3 +- migration/multifd.c | 12 +- migration/multifd.h | 5 + migration/options.c | 5 - migration/ram.c | 42 ++++++- 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, 437 insertions(+), 159 deletions(-)
Signature · 1 line
2.49.0
PATCH v9 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(-)
v8: 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.49.0
PATCH v9 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 | 132 +++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 61 deletions(-)
v8: remove else if (!mis->from_src_file) checks and add assert(3) check
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/migration.c +71 -61
@@ -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 */
@@ -931,9 +934,8 @@ static void migration_incoming_setup(QEMUFile *f) {MigrationIncomingState *mis =migration_incoming_get_current (); -if (!mis->from_src_file) { - mis->from_src_file = f; - } +assert (!mis->from_src_file); + mis->from_src_file = f;qemu_file_set_blocking (f, false); }
@@ -985,28 +987,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 +1008,81 @@ 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 ) { +assert (migrate_multifd ()); + 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 { - default_channel = !mis->from_src_file; +assert (migrate_postcopy_preempt ()); + channel =CH_POSTCOPY ; }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); - } +multifd_recv_new_channel (ioc, &local_err);if (local_err) {error_propagate (errp, local_err);return ; } + }else if (channel ==CH_POSTCOPY ) { +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 +1099,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.49.0
Re: [PATCH v9 2/7] migration: refactor channel discovery mechanism
Quoted 9 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.
Quoted 8 lines
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]>
PATCH v9 3/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: reorder this patch before enabling multifd and postcopy together
- 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
@@ -2717,6 +2717,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.49.0
Re: [PATCH v9 3/7] migration: Add save_postcopy_prepare() savevm handler
Quoted 12 lines · Prasad Pandit
From: 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.
Quoted 5 lines
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.
Signed-off-by Peter Xu <[email protected]>Signed-off-by Prasad Pandit <[email protected]>
PATCH v9 4/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.
--- migration/ram.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
v8: reorder patch and some typographical corrections.
- https://lore.kernel.org/qemu-devel/[email protected]/T/#t
migration/ram.c +37 -0
@@ -4420,6 +4420,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 have been flushed. +* +* 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 the destination side. +* +* This flush and sync will guarantee that those pages are loaded +* _before_ postcopy starts on the destination. The rationale is, +* this happens before VM stops (and before source QEMU sends all +* the rest of the postcopy messages). So when the destination QEMU +* receives 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 would guarantee that +* all previous guest pages queued in the multifd channels are +* 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 );
@@ -4439,6 +4475,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.49.0
Re: [PATCH v9 4/7] migration/ram: Implement save_postcopy_prepare()
Quoted 7 lines · Prasad Pandit
From: Peter Xu <[email protected]>
Implement
save_postcopy_prepare(), preparing for the enablement of both multifd and postcopy.Signed-off-by Peter Xu <[email protected]>Signed-off-by Prasad Pandit <[email protected]>
PATCH v9 5/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 | 5 ++--- 4 files changed, 11 insertions(+), 9 deletions(-)
v8: remove a !migration_in_postcopy() check
- 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 +2 -3
@@ -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.49.0
PATCH v9 6/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(-)
v8: 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.49.0
Re: [PATCH v9 6/7] tests/qtest/migration: consolidate set capabilities
Quoted 11 lines · Prasad Pandit
From: 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.Suggested-by Fabiano Rosas <[email protected]>Signed-off-by Prasad Pandit <[email protected]>
PATCH v9 7/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: no change
- 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.49.0
Re: [PATCH v9 7/7] tests/qtest/migration: add postcopy tests with multifd
Quoted 6 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Add new qtests to run postcopy migration with multifd channels enabled.
Signed-off-by Prasad Pandit <[email protected]>
Quoted 10 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Hello,
* This series (v9) does minor refactoring and reordering changes as suggested in the review of earlier series (v8). Also tried to reproduce/debug a qtest hang issue, but it could not be reproduced. From the shared stack traces it looked like Postcopy thread was preparing to finish before migrating all the pages.
The issue is that a zero page is being migrated by multifd but there's an optimization in place that skips faulting the page in on the destination. Later during postcopy when the page is found to be missing, postcopy (@migrate_send_rp_req_pages) believes the page is already present due to the receivedmap for that pfn being set and thus the code accessing the guest memory just sits there waiting for the page.
It seems your series has a logical conflict with this work that was done a while back:
https://lore.kernel.org/all/[email protected]/
The usage of receivedmap for multifd was supposed to be mutually exclusive with postcopy. Take a look at the description of that series and at postcopy_place_page_zero(). We need to figure out what needs to change and how to do that compatibly. It might just be the case of memsetting the zero page always for postcopy, but I havent't thought too much about it.
There's also other issues with the series:
https://gitlab.com/farosas/qemu/-/pipelines/1770488059
The CI workers don't support userfaultfd so the tests need to check for that properly. We have MigrationTestEnv::has_uffd for that.
Lastly, I have seem some weirdness with TLS channels disconnections leading to asserts in qio_channel_shutdown() in my testing. I'll get a better look at those tomorrow.
Quoted 34 lines · Fabiano Rosas
Quoted 10 lines · Prasad Pandit
From: Prasad Pandit <[email protected]>
Hello,
* This series (v9) does minor refactoring and reordering changes as suggested in the review of earlier series (v8). Also tried to reproduce/debug a qtest hang issue, but it could not be reproduced. From the shared stack traces it looked like Postcopy thread was preparing to finish before migrating all the pages.
The issue is that a zero page is being migrated by multifd but there's an optimization in place that skips faulting the page in on the destination. Later during postcopy when the page is found to be missing, postcopy (@migrate_send_rp_req_pages) believes the page is already present due to the receivedmap for that pfn being set and thus the code accessing the guest memory just sits there waiting for the page.
It seems your series has a logical conflict with this work that was done a while back:
https://lore.kernel.org/all/[email protected]/
The usage of receivedmap for multifd was supposed to be mutually exclusive with postcopy. Take a look at the description of that series and at
postcopy_place_page_zero(). We need to figure out what needs to change and how to do that compatibly. It might just be the case of memsetting the zero page always for postcopy, but I havent't thought too much about it.There's also other issues with the series:
Quoted 8 lines
https://gitlab.com/farosas/qemu/-/pipelines/1770488059
The CI workers don't support userfaultfd so the tests need to check for that properly. We have
MigrationTestEnv::has_uffdfor that.Lastly, I have seem some weirdness with TLS channels disconnections leading to asserts in
qio_channel_shutdown()in my testing. I'll get a better look at those tomorrow.
Ok, you can ignore this last paragraph. I was seeing the postcopy recovery test disconnect messages, those are benign.
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 10 lines
The issue is that a zero page is being migrated by multifd but there's an optimization in place that skips faulting the page in on the destination. Later during postcopy when the page is found to be missing, postcopy (@migrate_send_rp_req_pages) believes the page is already present due to the receivedmap for that pfn being set and thus the code accessing the guest memory just sits there waiting for the page.
It seems your series has a logical conflict with this work that was done a while back:
Quoted 8 lines
Quoted 8 lines
https://lore.kernel.org/all/[email protected]/
The usage of receivedmap for multifd was supposed to be mutually exclusive with postcopy. Take a look at the description of that series and at
postcopy_place_page_zero(). We need to figure out what needs to change and how to do that compatibly. It might just be the case of memsetting the zero page always for postcopy, but I havent't thought too much about it.
===
$ grep -i avx /proc/cpuinfo
flags : avx avx2 avx512f avx512dq avx512ifma avx512cd avx512bw
avx512vl avx512vbmi avx512_vbmi2 avx512_vnni avx512_bitalg
avx512_vpopcntdq avx512_vp2intersect
$
$ ./configure --enable-kvm --enable-avx512bw --enable-avx2
--disable-docs --target-list='x86_64-softmmu'
$ make -sj10 check-qtest
67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test
OK 193.80s 81 subtests passed
===* One of my machines does seem to support 'avx*' instructions. QEMU is configured and built with the 'avx2' and 'avx512bw' support. Still migration-tests run fine, without any hang issue observed. Not sure why the hang issue is not reproducing on my side. How do you generally build QEMU to run these tests? Does this issue require some specific h/w setup/support?
* Not sure how/why page faults happen during the Multifd phase when the guest on the destination is not running. If 'receivedmap' says that page is present, code accessing guest memory should just access whatever is available/present in that space, without waiting. I'll try to see what zero pages do, how page-faults occur during postcopy and how they are serviced. Let's see..
* Another suggestion is, maybe we should review and pull at least the refactoring patches so that in the next revisions we don't have to redo them. We can hold back the "enable multifd and postcopy together" patch that causes this guest hang issue to surface.
Quoted 7 lines
Quoted 7 lines
There's also other issues with the series:
https://gitlab.com/farosas/qemu/-/pipelines/1770488059
The CI workers don't support userfaultfd so the tests need to check for that properly. We have
MigrationTestEnv::has_uffdfor that.
Quoted 6 lines
Quoted 3 lines
Lastly, I have seem some weirdness with TLS channels disconnections leading to asserts in
qio_channel_shutdown()in my testing. I'll get a better look at those tomorrow.Ok, you can ignore this last paragraph. I was seeing the postcopy recovery test disconnect messages, those are benign.
* ie. ignore everything after - "There's also other issues with this
series: " ? OR just the last one " ...with TLS channels..." ?? Postcopy tests are added only if (env->has_uffd) check returns true.
Thank you.
---
- Prasad
Quoted 35 lines · Prasad Pandit
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 10 lines
The issue is that a zero page is being migrated by multifd but there's an optimization in place that skips faulting the page in on the destination. Later during postcopy when the page is found to be missing, postcopy (@migrate_send_rp_req_pages) believes the page is already present due to the receivedmap for that pfn being set and thus the code accessing the guest memory just sits there waiting for the page.
It seems your series has a logical conflict with this work that was done a while back:
Quoted 8 lines
Quoted 8 lines
https://lore.kernel.org/all/[email protected]/
The usage of receivedmap for multifd was supposed to be mutually exclusive with postcopy. Take a look at the description of that series and at
postcopy_place_page_zero(). We need to figure out what needs to change and how to do that compatibly. It might just be the case of memsetting the zero page always for postcopy, but I havent't thought too much about it.===
$ grep -i avx /proc/cpuinfo flags : avx avx2 avx512f avx512dq avx512ifma avx512cd avx512bw avx512vl avx512vbmi avx512_vbmi2 avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_vp2intersect $ $ ./configure --enable-kvm --enable-avx512bw --enable-avx2 --disable-docs --target-list='x86_64-softmmu' $ make -sj10 check-qtest 67/67 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test OK 193.80s 81 subtests passed ===
Quoted 7 lines
* One of my machines does seem to support 'avx*' instructions. QEMU is configured and built with the 'avx2' and 'avx512bw' support. Still migration-tests run fine, without any hang issue observed. Not sure why the hang issue is not reproducing on my side. How do you generally build QEMU to run these tests? Does this issue require some specific h/w setup/support?
There's nothing unusual here that I know of. Configure line is just --target-list=x86_64-softmmu --enable-debug --disable-docs --disable-plugins.
Quoted 6 lines
* Not sure how/why page faults happen during the Multifd phase when the guest on the destination is not running. If 'receivedmap' says that page is present, code accessing guest memory should just access whatever is available/present in that space, without waiting. I'll try to see what zero pages do, how page-faults occur during postcopy and how they are serviced. Let's see..
It's not that page faults happen during multifd. The page was already sent during precopy, but multifd-recv didn't write to it, it just marked the receivedmap. When postcopy starts, the page gets accessed and faults. Since postcopy is on, the migration wants to request the page from the source, but it's present in the receivedmap, so it doesn't ask. No page ever comes and the code hangs waiting for the page fault to be serviced (or potentially faults continuously? I'm not sure on the details).
Quoted 6 lines
* Another suggestion is, maybe we should review and pull at least the refactoring patches so that in the next revisions we don't have to redo them. We can hold back the "enable multifd and postcopy together" patch that causes this guest hang issue to surface.
That's reasonable. But I won't be available for the next two weeks. Peter is going to be back in the meantime, let's hear what he has to say about this postcopy issue. I'll provide my r-bs.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
There's also other issues with the series:
https://gitlab.com/farosas/qemu/-/pipelines/1770488059
The CI workers don't support userfaultfd so the tests need to check for that properly. We have
MigrationTestEnv::has_uffdfor that.Lastly, I have seem some weirdness with TLS channels disconnections leading to asserts in
qio_channel_shutdown()in my testing. I'll get a better look at those tomorrow.
Quoted 7 lines
Quoted 2 lines
Ok, you can ignore this last paragraph. I was seeing the postcopy recovery test disconnect messages, those are benign.
* ie. ignore everything after - "There's also other issues with this
series: " ? OR just the last one " ...with TLS channels..." ?? Postcopy tests are added only if (env->has_uffd) check returns true.
Only the TLS part. The CI is failing with just this series. I didn't change anything there. Maybe there's a bug in the userfaultfd detection? I'll leave it to you, here's the error:
# Running /ppc64/migration/multifd+postcopy/tcp/plain/cancel # Using machine type: pseries-10.0
# starting QEMU: exec ./qemu-system-ppc64 -qtest
# unix:/tmp/qtest-1305.sock -qtest-log /dev/null -chardev
# socket,path=/tmp/qtest-1305.qmp,id=char0 -mon
# chardev=char0,mode=control -display none -audio none -accel kvm -accel
# tcg -machine pseries-10.0,vsmt=8 -name source,debug-threads=on -m 256M
# -serial file:/tmp/migration-test-X0SO42/src_serial -nodefaults
# -machine
# cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off,
# -bios /tmp/migration-test-X0SO42/bootsect 2>/dev/null -accel qtest
# starting QEMU: exec ./qemu-system-ppc64 -qtest
# unix:/tmp/qtest-1305.sock -qtest-log /dev/null -chardev
# socket,path=/tmp/qtest-1305.qmp,id=char0 -mon
# chardev=char0,mode=control -display none -audio none -accel kvm -accel
# tcg -machine pseries-10.0,vsmt=8 -name target,debug-threads=on -m 256M
# -serial file:/tmp/migration-test-X0SO42/dest_serial -incoming defer
# -nodefaults -machine
# cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off,
# -bios /tmp/migration-test-X0SO42/bootsect 2>/dev/null -accel qtest
# {
# "error": {
# "class": "GenericError",
# "desc": "Postcopy is not supported: Userfaultfd not available: Function not implemented"
# }
# }Quoted 8 lines · Fabiano Rosas
It's not that page faults happen during multifd. The page was already sent during precopy, but multifd-recv didn't write to it, it just marked the receivedmap. When postcopy starts, the page gets accessed and faults. Since postcopy is on, the migration wants to request the page from the source, but it's present in the receivedmap, so it doesn't ask. No page ever comes and the code hangs waiting for the page fault to be serviced (or potentially faults continuously? I'm not sure on the details).
I think your previous analysis is correct on the zero pages. I am not 100% sure if that's the issue but very likely. I tend to also agree with you that we could skip zero page optimization in multifd code when postcopy is enabled (maybe plus some comment right above..).
Thanks,
Signature · 1 line
Peter Xu
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 8 lines
It's not that page faults happen during multifd. The page was already sent during precopy, but multifd-recv didn't write to it, it just marked the receivedmap. When postcopy starts, the page gets accessed and faults. Since postcopy is on, the migration wants to request the page from the source, but it's present in the receivedmap, so it doesn't ask. No page ever comes and the code hangs waiting for the page fault to be serviced (or potentially faults continuously? I'm not sure on the details).
Quoted 4 lines
I think your previous analysis is correct on the zero pages. I am not 100% sure if that's the issue but very likely. I tend to also agree with you that we could skip zero page optimization in multifd code when postcopy is enabled (maybe plus some comment right above..).
migration/multifd: solve zero page causing multiple page faults
-> https://gitlab.com/qemu-project/qemu/-/commit/5ef7e26bdb7eda10d6d5e1b77121be9945e5e550
* Is this the optimization that is causing the migration hang issue?
===
migration/multifd-zero-page.c +2 -1
@@ -85,7 +85,8 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (!migrate_postcopy () && +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); }else {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]);
===
* Would the above patch help to resolve it?
* Another way could be when the page fault occurs during postcopy phase, if we know (from receivedmap) that the faulted page is a zero-page, maybe we could write it locally on the destination to service the page-fault?
Quoted 11 lines · Fabiano Rosas
Maybe there's a bug in the userfaultfd detection? I'll leave it to you, here's the error:
# Running /ppc64/migration/multifd+postcopy/tcp/plain/cancel # Using machine type: pseries-10.0
# starting QEMU: exec ./qemu-system-ppc64 -qtest # { # "error": { # "class": "GenericError", # "desc": "Postcopy is not supported: Userfaultfd not available: Function not implemented" # } # }
* It is saying - function not implemented - does the Pseries machine not support userfaultfd?
Thank you.
---
- Prasad
Quoted 17 lines · Prasad Pandit
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 8 lines
It's not that page faults happen during multifd. The page was already sent during precopy, but multifd-recv didn't write to it, it just marked the receivedmap. When postcopy starts, the page gets accessed and faults. Since postcopy is on, the migration wants to request the page from the source, but it's present in the receivedmap, so it doesn't ask. No page ever comes and the code hangs waiting for the page fault to be serviced (or potentially faults continuously? I'm not sure on the details).
Quoted 4 lines
I think your previous analysis is correct on the zero pages. I am not 100% sure if that's the issue but very likely. I tend to also agree with you that we could skip zero page optimization in multifd code when postcopy is enabled (maybe plus some comment right above..).
Quoted 4 lines
migration/multifd: solve zero page causing multiple page faults
-> https://gitlab.com/qemu-project/qemu/-/commit/5ef7e26bdb7eda10d6d5e1b77121be9945e5e550* Is this the optimization that is causing the migration hang issue?
I think that's what Fabiano mentioned, but ultimately we need to verify it on a reproducer to know.
Quoted 18 lines
===
migration/multifd-zero-page.c +2
-1@@ -85,7 +85,8 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (!migrate_postcopy () && +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); }else {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]);===
Quoted 1 line
* Would the above patch help to resolve it?
Looks ok, but please add some comments explain why postcopy needs to do it, and especially do it during precopy phase.
I'd use migrate_postcopy_ram() instead. I wished migrate_dirty_bitmaps() has a better name, maybe migrate_postcopy_block().. I have totally no idea who is using the feature, especially when postcopy-ram is off.
Quoted 5 lines
* Another way could be when the page fault occurs during postcopy phase, if we know (from receivedmap) that the faulted page is a zero-page, maybe we could write it locally on the destination to service the page-fault?
I don't think we can know that - receivedmap set doesn't mean it's a zero page, but only says it's been received before. It can also happen e.g. >1 threads faulted on the same page then the 2nd thread faulted on it may see receivedmap set because the 1st thread got faulted already got the fault resolved.
Signature · 1 line
Peter Xu
Quoted 2 lines · Peter Xu
I think that's what Fabiano mentioned, but ultimately we need to verify it on a reproducer to know.
...
Quoted 4 lines
Looks ok, but please add some comments explain why postcopy needs to do it, and especially do it during precopy phase.
I'd use
migrate_postcopy_ram()instead.
* Okay. It should be '||' instead of '&&' in the first conditional I think, we want to write zeropage when postcopy is enabled.
===
migration/multifd-zero-page.c +4 -2
@@ -85,9 +85,11 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (migrate_postcopy_ram () || +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); - }else { + } +if (!ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]); } }
===
* I'll send this one if it looks okay.
Quoted 5 lines
I don't think we can know that - receivedmap set doesn't mean it's a zero page, but only says it's been received before. It can also happen e.g. >1 threads faulted on the same page then the 2nd thread faulted on it may see receivedmap set because the 1st thread got faulted already got the fault resolved.
* Okay.
Thank you.
---
- Prasad
Quoted 30 lines · Prasad Pandit
Quoted 2 lines · Peter Xu
I think that's what Fabiano mentioned, but ultimately we need to verify it on a reproducer to know.
...
Quoted 4 lines
Looks ok, but please add some comments explain why postcopy needs to do it, and especially do it during precopy phase.
I'd use
migrate_postcopy_ram()instead.* Okay. It should be '||' instead of '&&' in the first conditional I think, we want to write zeropage when postcopy is enabled.
===migration/multifd-zero-page.c +4
-2@@ -85,9 +85,11 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (migrate_postcopy_ram () || +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); - }else { + } +if (!ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]); } }
Quoted 2 lines
===
* I'll send this one if it looks okay.
Please don't rush to send. Again, let's verify the issue first before resending anything.
If you could reproduce it it would be perfect, then we can already verify it. Otherwise we may need help from Fabiano. Let's not send anything if you're not yet sure whether it works.. It can confuse people thinking problem solved, but maybe not yet.
Signature · 1 line
Peter Xu
Quoted 7 lines · Peter Xu
Please don't rush to send. Again, let's verify the issue first before resending anything.
If you could reproduce it it would be perfect, then we can already verify it. Otherwise we may need help from Fabiano. Let's not send anything if you're not yet sure whether it works.. It can confuse people thinking problem solved, but maybe not yet.
* No, the migration hang issue is not reproducing on my side. Earlier in this thread, Fabiano said you'll be better able to confirm the issue. (so its possible fix as well I guess)
* You don't have access to the set-up that he uses for running tests and merging patches? Would it be possible for you to run the same tests? (just checking, I don't know how co-maintainers work to test/merge patches)
* If we don't send the patch, how will Fabiano test it? Should we wait for Fabiano to come back and then make this same patch in his set-up and test/verify it?
Thank you.
---
- Prasad
Quoted 9 lines · Prasad Pandit
Quoted 7 lines · Peter Xu
Please don't rush to send. Again, let's verify the issue first before resending anything.
If you could reproduce it it would be perfect, then we can already verify it. Otherwise we may need help from Fabiano. Let's not send anything if you're not yet sure whether it works.. It can confuse people thinking problem solved, but maybe not yet.
Quoted 8 lines
* No, the migration hang issue is not reproducing on my side. Earlier in this thread, Fabiano said you'll be better able to confirm the issue. (so its possible fix as well I guess)
* You don't have access to the set-up that he uses for running tests and merging patches? Would it be possible for you to run the same tests? (just checking, I don't know how co-maintainers work to test/merge patches)
No I don't.
Quoted 4 lines
* If we don't send the patch, how will Fabiano test it? Should we wait for Fabiano to come back and then make this same patch in his set-up and test/verify it?
I thought you've provided a diff. That would be good enough for verifications. If you really want, you can repost, but please mention explicitly that you haven't verified the issue, so the patchset needs to be verified.
Fabiano should come back early May. If you want, you can try to look into how to reproduce it by looking at why it triggered in vapic path:
https://lore.kernel.org/all/[email protected]/#t
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
So _if_ the theory is correct, vapic's patch_hypercalls() might be reading a zero page (with GPA 831488, over len=9216, which IIUC covers three pages). Maybe you can check when it'll be one zero page and when it will be not, then maybe you can figure out how you make it always a zero page hence reliably trigger a hang in post_load.
You could also try to write a program in guest, zeroing most pages first, trigger migrate (hence send zero pages during multifd precopy), start postcopy, then you should be able to observe vcpu hang at least before postcopy completes. However I don't think it'll hang forever, since if migration all completes, UFFDIO_UNREGISTER will remove the userfaultfd trackings and then kick all hang threads out, causing the fault to be resolved right at the completion of postcopy. So it won't really hang forever like what Fabiano reported here. Meanwhile we'll always want to verify the original reproducer.. even if you could hang it temporarily in a vcpu thread.
Thanks,
Signature · 1 line
Peter Xu
Quoted 30 lines · Prasad Pandit
Quoted 2 lines · Peter Xu
I think that's what Fabiano mentioned, but ultimately we need to verify it on a reproducer to know.
...
Quoted 4 lines
Looks ok, but please add some comments explain why postcopy needs to do it, and especially do it during precopy phase.
I'd use
migrate_postcopy_ram()instead.* Okay. It should be '||' instead of '&&' in the first conditional I think, we want to write zeropage when postcopy is enabled.
===migration/multifd-zero-page.c +4
-2@@ -85,9 +85,11 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (migrate_postcopy_ram () || +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); - }else { + } +if (!ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]); } }
Quoted 1 line
===
I applied this diff and I'm not seeing the hang anymore.
Hello Fabiano,
Quoted 10 lines · Fabiano Rosas
Quoted 10 lines
+++
b/migration/multifd-zero-page.cmigration/multifd-zero-page.c +2
-2@@ -85,9 +85,11 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (migrate_postcopy_ram () || +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); - }else {
Quoted 8 lines
Quoted 6 lines
migration/multifd-zero-page.c +2
-0+ } +if (!ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]); } }===
I applied this diff and I'm not seeing the hang anymore.
* Great, thank you for the confirmation. I'll prepare a formal patch.
Thank you.
---
- Prasad
Quoted 59 lines · Prasad Pandit
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 8 lines
It's not that page faults happen during multifd. The page was already sent during precopy, but multifd-recv didn't write to it, it just marked the receivedmap. When postcopy starts, the page gets accessed and faults. Since postcopy is on, the migration wants to request the page from the source, but it's present in the receivedmap, so it doesn't ask. No page ever comes and the code hangs waiting for the page fault to be serviced (or potentially faults continuously? I'm not sure on the details).
Quoted 4 lines
I think your previous analysis is correct on the zero pages. I am not 100% sure if that's the issue but very likely. I tend to also agree with you that we could skip zero page optimization in multifd code when postcopy is enabled (maybe plus some comment right above..).
migration/multifd: solve zero page causing multiple page faults
-> https://gitlab.com/qemu-project/qemu/-/commit/5ef7e26bdb7eda10d6d5e1b77121be9945e5e550* Is this the optimization that is causing the migration hang issue?
===
migration/multifd-zero-page.c +2
-1@@ -85,7 +85,8 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) {for (int i =0 ; i < p->zero_num; i++) {void *page = p->host + p->zero[i]; -if (ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) { +if (!migrate_postcopy () && +ramblock_recv_bitmap_test_byte_offset (p->block, p->zero[i])) {memset (page,0 ,multifd_ram_page_size ()); }else {ramblock_recv_bitmap_set_offset (p->block, p->zero[i]);===
* Would the above patch help to resolve it?
* Another way could be when the page fault occurs during postcopy phase, if we know (from receivedmap) that the faulted page is a zero-page, maybe we could write it locally on the destination to service the page-fault?
Quoted 11 lines · Fabiano Rosas
Maybe there's a bug in the userfaultfd detection? I'll leave it to you, here's the error:
# Running /ppc64/migration/multifd+postcopy/tcp/plain/cancel # Using machine type: pseries-10.0
# starting QEMU: exec ./qemu-system-ppc64 -qtest # { # "error": { # "class": "GenericError", # "desc": "Postcopy is not supported: Userfaultfd not available: Function not implemented" # } # }
Quoted 3 lines
* It is saying - function not implemented - does the Pseries machine not support userfaultfd?
We're missing a check on has_uffd for the multifd+postcopy tests.
Quoted 3 lines
Thank you.
---
- Prasad
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 10 lines
Quoted 9 lines
# Running /ppc64/migration/multifd+postcopy/tcp/plain/cancel # Using machine type: pseries-10.0
# starting QEMU: exec ./qemu-system-ppc64 -qtest # { # "error": { # "class": "GenericError", # "desc": "Postcopy is not supported: Userfaultfd not available: Function not implemented" # } # }
===
[ ~]#
...
PPC KVM module is not loaded. Try modprobe kvm_hv.
qemu-system-ppc64: -accel kvm: failed to initialize kvm: Invalid argument
qemu-system-ppc64: -accel kvm: ioctl(KVM_CREATE_VM) failed: Invalid argument PPC KVM module is not loaded. Try modprobe kvm_hv.
qemu-system-ppc64: -accel kvm: failed to initialize kvm: Invalid argument [ ~]#
[ ~]# modprobe kvm-hv
modprobe: ERROR: could not insert 'kvm_hv': No such device [ ~]#
[ ~]# ls -l /dev/kvm /dev/userfaultfd
crw-rw-rw-. 1 root kvm 10, 232 May 6 07:06 /dev/kvm crw----rw-. 1 root root 10, 123 May 6 06:30 /dev/userfaultfd [ ~]#
===
* I tried to reproduce this issue across multiple Power9 and Power10 machines, but I -qtest could not run due to above errors.
Quoted 1 line
We're missing a check on
has_uffdfor the multifd+postcopy tests.
* If it is about missing the 'e->has_uffd' check, does that mean Postcopy tests are skipped on this machine because 'e->has_uffd' is false?
Thank you.
---
- Prasad
Quoted 13 lines · Prasad Pandit
Hi,
Quoted 10 lines · Fabiano Rosas
Quoted 10 lines
Quoted 9 lines
# Running /ppc64/migration/multifd+postcopy/tcp/plain/cancel # Using machine type: pseries-10.0
# starting QEMU: exec ./qemu-system-ppc64 -qtest # { # "error": { # "class": "GenericError", # "desc": "Postcopy is not supported: Userfaultfd not available: Function not implemented" # } # }
Quoted 8 lines
===
[ ~]#
...
PPC KVM module is not loaded. Try modprobekvm_hv.
qemu-system-ppc64: -accel kvm: failed to initialize kvm: Invalid argument
qemu-system-ppc64: -accel kvm:ioctl(KVM_CREATE_VM)failed: Invalid argument PPC KVM module is not loaded. Try modprobekvm_hv.
qemu-system-ppc64: -accel kvm: failed to initialize kvm: Invalid argument
The tests should fallback to TCG and that should be enough to reproduce this issue. I don't think you even need a ppc machine, the CI uses a x86_64 container.
Quoted 11 lines
[ ~]#
[ ~]# modprobe kvm-hv
modprobe: ERROR: could not insert 'kvm_hv': No such device [ ~]#
[ ~]# ls -l/dev/kvm/dev/userfaultfd
crw-rw-rw-. 1 root kvm 10, 232 May 6 07:06/dev/kvmcrw----rw-. 1 root root 10, 123 May 6 06:30/dev/userfaultfd[ ~]#
===
Quoted 3 lines
* I tried to reproduce this issue across multiple Power9 and Power10 machines, but I -qtest could not run due to above errors.
There are several considerations to take into account with ppc64le, you probably have either a distro version that doesn't provide the KVM module or a machine that doesn't have KVM support at all.
Quoted 6 lines
Quoted 1 line
We're missing a check on
has_uffdfor the multifd+postcopy tests.* If it is about missing the '
e->has_uffd' check, does that mean Postcopy tests are skipped on this machine because 'e->has_uffd' is false?
I haven't verified, but yes, the ones that check has_uffd should be skipped.
I don't think you need to go to the extent to reproduce this. Look at migrate_caps_check(), whenever postcopy-ram is enabled for the first time, it will call postcopy_ram_supported_by_host(), so it follows that any test that enables postcopy-ram must first check env->has_uffd.
Quoted 4 lines
Thank you.
---
- Prasad