To support query migration thread infomation, save and delete
thread information at thread creation and end.
Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
---
migration/migration.c | 4 ++++
migration/multifd.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/migration/migration.c b/migration/migration.c
index b4ce458bb9..957205e693 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -57,6 +57,7 @@
#include "net/announce.h"
#include "qemu/queue.h"
#include "multifd.h"
+#include "threadinfo.h"
#include "qemu/yank.h"
#include "sysemu/cpus.h"
#include "yank_functions.h"
@@ -3951,10 +3952,12 @@ static void qemu_savevm_wait_unplug(MigrationState *s, int old_state,
static void *migration_thread(void *opaque)
{
MigrationState *s = opaque;
+ MigrationThread *thread = NULL;
int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST);
MigThrError thr_error;
bool urgent = false;
+ thread = MigrationThreadAdd("live_migration", qemu_get_thread_id());
/* report migration thread name to libvirt */
qapi_event_send_migration_name("live_migration");
@@ -4034,6 +4037,7 @@ static void *migration_thread(void *opaque)
migration_iteration_finish(s);
object_unref(OBJECT(s));
rcu_unregister_thread();
+ MigrationThreadDel(thread);
return NULL;
}
diff --git a/migration/multifd.c b/migration/multifd.c
index 6e834c7111..fca06284de 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -25,6 +25,7 @@
#include "qemu-file.h"
#include "trace.h"
#include "multifd.h"
+#include "threadinfo.h"
#include "qemu/yank.h"
#include "io/channel-socket.h"
#include "yank_functions.h"
@@ -646,10 +647,12 @@ int multifd_send_sync_main(QEMUFile *f)
static void *multifd_send_thread(void *opaque)
{
MultiFDSendParams *p = opaque;
+ MigrationThread *thread = NULL;
Error *local_err = NULL;
int ret = 0;
bool use_zero_copy_send = migrate_use_zero_copy_send();
+ thread = MigrationThreadAdd(p->name, qemu_get_thread_id());
/* report multifd thread name to libvirt */
qapi_event_send_migration_name(p->name);
@@ -762,6 +765,7 @@ out:
qemu_mutex_unlock(&p->mutex);
rcu_unregister_thread();
+ MigrationThreadDel(thread);
trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages);
return NULL;
--
2.33.0
Jiang Jiacheng <jiangjiacheng@huawei.com> wrote:
> To support query migration thread infomation, save and delete
> thread information at thread creation and end.
>
> Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Don't disagree with this, but if we create this on the sending side, why
this is not needed for the multifd_recv_threads?
Later, Juan.
> ---
> migration/migration.c | 4 ++++
> migration/multifd.c | 4 ++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index b4ce458bb9..957205e693 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -57,6 +57,7 @@
> #include "net/announce.h"
> #include "qemu/queue.h"
> #include "multifd.h"
> +#include "threadinfo.h"
> #include "qemu/yank.h"
> #include "sysemu/cpus.h"
> #include "yank_functions.h"
> @@ -3951,10 +3952,12 @@ static void qemu_savevm_wait_unplug(MigrationState *s, int old_state,
> static void *migration_thread(void *opaque)
> {
> MigrationState *s = opaque;
> + MigrationThread *thread = NULL;
> int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST);
> MigThrError thr_error;
> bool urgent = false;
>
> + thread = MigrationThreadAdd("live_migration", qemu_get_thread_id());
> /* report migration thread name to libvirt */
> qapi_event_send_migration_name("live_migration");
>
> @@ -4034,6 +4037,7 @@ static void *migration_thread(void *opaque)
> migration_iteration_finish(s);
> object_unref(OBJECT(s));
> rcu_unregister_thread();
> + MigrationThreadDel(thread);
> return NULL;
> }
>
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 6e834c7111..fca06284de 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -25,6 +25,7 @@
> #include "qemu-file.h"
> #include "trace.h"
> #include "multifd.h"
> +#include "threadinfo.h"
> #include "qemu/yank.h"
> #include "io/channel-socket.h"
> #include "yank_functions.h"
> @@ -646,10 +647,12 @@ int multifd_send_sync_main(QEMUFile *f)
> static void *multifd_send_thread(void *opaque)
> {
> MultiFDSendParams *p = opaque;
> + MigrationThread *thread = NULL;
> Error *local_err = NULL;
> int ret = 0;
> bool use_zero_copy_send = migrate_use_zero_copy_send();
>
> + thread = MigrationThreadAdd(p->name, qemu_get_thread_id());
> /* report multifd thread name to libvirt */
> qapi_event_send_migration_name(p->name);
>
> @@ -762,6 +765,7 @@ out:
> qemu_mutex_unlock(&p->mutex);
>
> rcu_unregister_thread();
> + MigrationThreadDel(thread);
> trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages);
>
> return NULL;
On 2023/1/30 12:28, Juan Quintela wrote:
> Jiang Jiacheng <jiangjiacheng@huawei.com> wrote:
>> To support query migration thread infomation, save and delete
>> thread information at thread creation and end.
>>
>> Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
>
> Don't disagree with this, but if we create this on the sending side, why
> this is not needed for the multifd_recv_threads?
>
I only add several threads which i'm interested in into the list till
now, whose information will be used for setting cpu affinity for
migration thread.
For consistency, we can add other threads to the list, but those
information won't be used so far.
Thanks, Jiang Jiacheng
> Later, Juan.
>
>> ---
>> migration/migration.c | 4 ++++
>> migration/multifd.c | 4 ++++
>> 2 files changed, 8 insertions(+)
>>
>> diff --git a/migration/migration.c b/migration/migration.c
>> index b4ce458bb9..957205e693 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -57,6 +57,7 @@
>> #include "net/announce.h"
>> #include "qemu/queue.h"
>> #include "multifd.h"
>> +#include "threadinfo.h"
>> #include "qemu/yank.h"
>> #include "sysemu/cpus.h"
>> #include "yank_functions.h"
>> @@ -3951,10 +3952,12 @@ static void qemu_savevm_wait_unplug(MigrationState *s, int old_state,
>> static void *migration_thread(void *opaque)
>> {
>> MigrationState *s = opaque;
>> + MigrationThread *thread = NULL;
>> int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST);
>> MigThrError thr_error;
>> bool urgent = false;
>>
>> + thread = MigrationThreadAdd("live_migration", qemu_get_thread_id());
>> /* report migration thread name to libvirt */
>> qapi_event_send_migration_name("live_migration");
>>
>> @@ -4034,6 +4037,7 @@ static void *migration_thread(void *opaque)
>> migration_iteration_finish(s);
>> object_unref(OBJECT(s));
>> rcu_unregister_thread();
>> + MigrationThreadDel(thread);
>> return NULL;
>> }
>
>
>>
>> diff --git a/migration/multifd.c b/migration/multifd.c
>> index 6e834c7111..fca06284de 100644
>> --- a/migration/multifd.c
>> +++ b/migration/multifd.c
>> @@ -25,6 +25,7 @@
>> #include "qemu-file.h"
>> #include "trace.h"
>> #include "multifd.h"
>> +#include "threadinfo.h"
>> #include "qemu/yank.h"
>> #include "io/channel-socket.h"
>> #include "yank_functions.h"
>> @@ -646,10 +647,12 @@ int multifd_send_sync_main(QEMUFile *f)
>> static void *multifd_send_thread(void *opaque)
>> {
>> MultiFDSendParams *p = opaque;
>> + MigrationThread *thread = NULL;
>> Error *local_err = NULL;
>> int ret = 0;
>> bool use_zero_copy_send = migrate_use_zero_copy_send();
>>
>> + thread = MigrationThreadAdd(p->name, qemu_get_thread_id());
>> /* report multifd thread name to libvirt */
>> qapi_event_send_migration_name(p->name);
>>
>> @@ -762,6 +765,7 @@ out:
>> qemu_mutex_unlock(&p->mutex);
>>
>> rcu_unregister_thread();
>> + MigrationThreadDel(thread);
>> trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages);
>>
>> return NULL;
>
Jiang Jiacheng <jiangjiacheng@huawei.com> wrote: > On 2023/1/30 12:28, Juan Quintela wrote: >> Jiang Jiacheng <jiangjiacheng@huawei.com> wrote: >>> To support query migration thread infomation, save and delete >>> thread information at thread creation and end. >>> >>> Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> >> >> Don't disagree with this, but if we create this on the sending side, why >> this is not needed for the multifd_recv_threads? >> > > I only add several threads which i'm interested in into the list till > now, whose information will be used for setting cpu affinity for > migration thread. > For consistency, we can add other threads to the list, but those > information won't be used so far. It is just curiosity, why do you want to set cpu affinity on the source but not on destination? Later, Juan.
On 2023/1/30 22:04, Juan Quintela wrote: > Jiang Jiacheng <jiangjiacheng@huawei.com> wrote: >> On 2023/1/30 12:28, Juan Quintela wrote: >>> Jiang Jiacheng <jiangjiacheng@huawei.com> wrote: >>>> To support query migration thread infomation, save and delete >>>> thread information at thread creation and end. >>>> >>>> Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> >>> >>> Don't disagree with this, but if we create this on the sending side, why >>> this is not needed for the multifd_recv_threads? >>> >> >> I only add several threads which i'm interested in into the list till >> now, whose information will be used for setting cpu affinity for >> migration thread. >> For consistency, we can add other threads to the list, but those >> information won't be used so far. > > It is just curiosity, why do you want to set cpu affinity on the source > but not on destination? > Mainly considering the application scenarios. To improve the migration performance, I want to set cpu affinity for migration thread when migration a VM whose service threads preempt most of the CPU resources. So the source side can benefit more from cpu affinity. And on the destination side, the pressure is lighter (generally), setting cpu affinity may not be so much useful as source side. Thanks, Jiang Jiacheng > Later, Juan. > >
© 2016 - 2026 Red Hat, Inc.