[RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt

Jiang Jiacheng via posted 2 patches 3 years, 1 month ago
Maintainers: Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
[RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt
Posted by Jiang Jiacheng via 3 years, 1 month ago
From: Zheng Chuan <zhengchuan@huawei.com>

Report multiFd related thread pid to libvirt in order to
pin multiFd thread to different cpu.
---
 migration/multifd.c |  4 ++++
 qapi/migration.json | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/migration/multifd.c b/migration/multifd.c
index 000ca4d4ec..f3f7e8ae31 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -17,6 +17,7 @@
 #include "exec/ramblock.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "qapi/qapi-events-migration.h"
 #include "ram.h"
 #include "migration.h"
 #include "socket.h"
@@ -650,6 +651,9 @@ static void *multifd_send_thread(void *opaque)
     int ret = 0;
     bool use_zero_copy_send = migrate_use_zero_copy_send();
 
+    /* report multifd thread pid to libvirt */
+    qapi_event_send_migration_multifd_pid(qemu_get_thread_id());
+
     trace_multifd_send_thread_start(p->id);
     rcu_register_thread();
 
diff --git a/qapi/migration.json b/qapi/migration.json
index aafc940617..33fc319329 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1286,6 +1286,18 @@
 { 'event': 'MIGRATION_PASS',
   'data': { 'pass': 'int' } }
 
+##
+# @MIGRATION_MULTIFD_PID:
+#
+# Emitted when multifd thread appear
+#
+# @pid: pid of multifd thread
+#
+# Since: 7.2
+##
+{ 'event': 'MIGRATION_MULTIFD_PID',
+  'data': { 'pid': 'int' } }
+
 ##
 # @MIGRATION_PID:
 #
-- 
2.33.0
Re: [RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt
Posted by Dr. David Alan Gilbert 3 years ago
* Jiang Jiacheng via (qemu-devel@nongnu.org) wrote:
> From: Zheng Chuan <zhengchuan@huawei.com>
> 
> Report multiFd related thread pid to libvirt in order to
> pin multiFd thread to different cpu.

With multifd you may well want to pin different multifd threads
to different cores; so you need to include the 'id' and 'name' fields of
the multifd thread in the event.

(Copying in Jiri and Dan )

Dave

> ---
>  migration/multifd.c |  4 ++++
>  qapi/migration.json | 12 ++++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 000ca4d4ec..f3f7e8ae31 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -17,6 +17,7 @@
>  #include "exec/ramblock.h"
>  #include "qemu/error-report.h"
>  #include "qapi/error.h"
> +#include "qapi/qapi-events-migration.h"
>  #include "ram.h"
>  #include "migration.h"
>  #include "socket.h"
> @@ -650,6 +651,9 @@ static void *multifd_send_thread(void *opaque)
>      int ret = 0;
>      bool use_zero_copy_send = migrate_use_zero_copy_send();
>  
> +    /* report multifd thread pid to libvirt */
> +    qapi_event_send_migration_multifd_pid(qemu_get_thread_id());
> +
>      trace_multifd_send_thread_start(p->id);
>      rcu_register_thread();
>  
> diff --git a/qapi/migration.json b/qapi/migration.json
> index aafc940617..33fc319329 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -1286,6 +1286,18 @@
>  { 'event': 'MIGRATION_PASS',
>    'data': { 'pass': 'int' } }
>  
> +##
> +# @MIGRATION_MULTIFD_PID:
> +#
> +# Emitted when multifd thread appear
> +#
> +# @pid: pid of multifd thread
> +#
> +# Since: 7.2
> +##
> +{ 'event': 'MIGRATION_MULTIFD_PID',
> +  'data': { 'pid': 'int' } }
> +
>  ##
>  # @MIGRATION_PID:
>  #
> -- 
> 2.33.0
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Re: [RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt
Posted by Daniel P. Berrangé 3 years ago
On Wed, Jan 11, 2023 at 07:00:53PM +0000, Dr. David Alan Gilbert wrote:
> * Jiang Jiacheng via (qemu-devel@nongnu.org) wrote:
> > From: Zheng Chuan <zhengchuan@huawei.com>
> > 
> > Report multiFd related thread pid to libvirt in order to
> > pin multiFd thread to different cpu.
> 
> With multifd you may well want to pin different multifd threads
> to different cores; so you need to include the 'id' and 'name' fields of
> the multifd thread in the event.

Are the 'id' / 'name' fields considered stable API for QEMU ?

IIRC, the mgmt app merely requests the number of multifd threads
and doesn't assign any identifying names/ids to them, unlike
iothreads where the mgmt app gives an explicit 'id'.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [RESEND PATCH 2/2] migration: report multiFd related thread pid to libvirt
Posted by Jiang Jiacheng via 3 years ago

On 2023/1/12 3:04, Daniel P. Berrangé wrote:
> On Wed, Jan 11, 2023 at 07:00:53PM +0000, Dr. David Alan Gilbert wrote:
>> * Jiang Jiacheng via (qemu-devel@nongnu.org) wrote:
>>> From: Zheng Chuan <zhengchuan@huawei.com>
>>>
>>> Report multiFd related thread pid to libvirt in order to
>>> pin multiFd thread to different cpu.
>>
>> With multifd you may well want to pin different multifd threads
>> to different cores; so you need to include the 'id' and 'name' fields of
>> the multifd thread in the event.
> 
> Are the 'id' / 'name' fields considered stable API for QEMU ?
> 
> IIRC, the mgmt app merely requests the number of multifd threads
> and doesn't assign any identifying names/ids to them, unlike
> iothreads where the mgmt app gives an explicit 'id'.
> 
> 

If the 'id'/'name' of the migration thread is fixed in QEMU API, I think
the related information can be added to the mgmt app to implement
migration thread pin more properly.
And we are considering another choice, which provides a list of
migration thread information for the mgmt app to actively query, so as
to provide more information and avoid exposing thread PIDs to the mgmt
app's public API.

Thanks
Jiang Jiacheng